A Method for Constructing a Legal and Standards Knowledge Base Based on a Large Language Model
By constructing a legal and standard knowledge base using a large language model, the problem of adapting the hierarchical structure and semantic relationships of legal texts is solved, enabling efficient and accurate legal retrieval and multi-dimensional retrieval, which is suitable for localized compliance knowledge services.
Patent Information
- Application Number
- CN202610112550.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-27
- Publication Date
- 2026-05-26
AI Technical Summary
Existing technologies are ill-suited to the hierarchical structure and complex semantic relationships of regulatory and standard texts, resulting in insufficient retrieval accuracy and completeness in knowledge base construction.
We adopt a legal and standard knowledge base construction method based on a large language model. We identify the full-level directory structure through semantic block processing, extract entity relationships and keywords, generate hierarchical summaries, and construct a hybrid storage structure to support multi-dimensional retrieval.
It achieves hierarchical preservation and semantic integrity of the legal and standard knowledge base, improves the relevance and accuracy of search results, meets multi-dimensional search needs, and adapts to localized compliance knowledge services.
Smart Images

Figure CN122087028A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of natural language processing technology, and in particular to a method, apparatus, device and medium for constructing a legal and standard knowledge base based on a large language model, as well as a retrieval method. Background Technology
[0002] With the increasing importance of compliance management, enterprises and other organizations urgently need to build a legal and standards knowledge base within their internal network environment, encompassing national laws and regulations, industry standards, local regulations, and internal normative documents, to support core business functions such as compliance retrieval, risk warning, and decision support. How to accurately and efficiently acquire, understand, and apply relevant legal standards has become a core technical challenge in knowledge base construction.
[0003] Among related technologies, the mainstream technical approach for constructing regulatory and standard knowledge bases is the Retrieval Augmentation (RAG) model. Its core process involves storing regulatory texts in chunks within a vector library, retrieving similar text fragments using an embedding similarity algorithm, and then generating responses using a large language model. However, this type of RAG model is difficult to adapt to the domain characteristics of regulatory texts.
[0004] Because regulatory and standard texts have the following characteristics: First, they have a strong hierarchical structure of "chapter-section-article-clause-item-subject", and knowledge units need to rely on hierarchical relationships to achieve complete expression; second, they are dense with professional terms and have strong correlations, and the understanding of a single term depends on the context and cross-clause references; third, cross-document / cross-chapter references are common, and semantic coherence needs to be achieved through reference relationships.
[0005] In RAG mode, text chunking primarily involves methods such as character segmentation, marker segmentation, hierarchical segmentation, and semantic segmentation. Character segmentation splits text into segments based on a fixed character length; marker segmentation is based on punctuation marks, line breaks, and other symbols; hierarchical segmentation simply identifies chapter-section headings; and semantic segmentation is based on a general semantic model. This chunking method has the following limitations: 1. Mechanical splitting leads to the destruction of the integrity of knowledge units, the inability of text chunks to be accurately aligned with the legal logic framework, and the lack of structured knowledge units, which directly affects the realization of in-depth application scenarios such as hierarchical retrieval and correlation analysis; 2. The segmentation method relies solely on the content breakdown of the text itself, failing to capture the complex semantic dependencies within and between regulations. This makes it difficult for the model to understand the inherent logic of the regulations, significantly reducing the accuracy of legal information retrieval and exposing its insufficient adaptability to regulatory texts.
[0006] Furthermore, the indexing of its knowledge base generally relies on keyword matching or a single semantic vector, resulting in poor matching accuracy for multi-dimensional information such as hierarchical features of regulatory texts and cross-document reference relationships. Summary of the Invention
[0007] This invention provides a method, apparatus, device, and medium for constructing a regulatory and standard knowledge base based on a large language model, as well as a retrieval method, which solves the problem of how to construct a regulatory and standard knowledge base that is easy to retrieve.
[0008] To achieve the above objectives, this application adopts the following technical solution: Firstly, a method for constructing a regulatory and standard knowledge base based on a large language model is provided, including: Obtain multiple regulatory and standard documents and convert them into standardized text data; Based on a preset prompt word template, the text data is semantically segmented using a large language model; The prompt word template is used to guide the large language model to recognize the full-level directory structure of <chapter-section-article-clause-item-subject> in the text data, and to perform semantic block processing based on the full-level directory structure; the result generated by the semantic block processing includes: text blocks, block indexes, hierarchical path information, and parent node indexes; the text block includes at least: each level of directory in the full-level directory structure, and optionally includes: the main text content corresponding to each level of directory; Based on the results generated by the semantic segmentation process, entity relationships and keywords are extracted using the large language model, and a hierarchical summary is generated. A file index is constructed based on the entity relationships, the keywords, and the hierarchical summary; the text blocks, block indexes, hierarchical path information, parent node indexes, and file indexes are stored in the knowledge base according to a predefined knowledge storage structure. The document index includes at least a regulatory and standard document index and a directory index; The knowledge storage structure includes at least an index area, an entry text area, and a case area.
[0009] Secondly, a device for constructing a legal and standard knowledge base based on a large language model is provided, including: The document acquisition module is used to acquire multiple regulatory and standard documents and convert them into standardized text data; The semantic segmentation processing module is used to perform semantic segmentation processing on the text data based on a preset prompt word template and a large language model. The prompt word template is used to guide the large language model to recognize the full-level directory structure of <chapter-section-article-clause-item-subject> in the text data, and to perform semantic block processing based on the full-level directory structure; the result generated by the semantic block processing includes: text blocks, block indexes, hierarchical path information, and parent node indexes; the text block includes at least: each level of directory in the full-level directory structure, and optionally includes: the main text content corresponding to each level of directory; The semantic enhancement module is used to extract entity relationships and keywords based on the results generated by the semantic segmentation process, and to generate hierarchical summaries using the large language model. The knowledge storage module is used to construct a file index based on the entity relationship, the keywords, and the hierarchical summary; and to store the text blocks, block indexes, hierarchical path information, parent node indexes, and file indexes into the knowledge base according to a predefined knowledge storage structure. The document index includes at least a regulatory and standard document index and a directory index; The knowledge storage structure includes at least an index area, an entry text area, and a case area.
[0010] Thirdly, a retrieval method is provided, including: Receive natural language search commands; In response to the natural language retrieval command, a retrieval is performed based on a regulatory and standards knowledge base constructed using the method described in the first aspect, and an answer result is generated.
[0011] Fourthly, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, performs the steps of the method as described in the first aspect.
[0012] Fifthly, a readable storage medium is provided, on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method as described in the first aspect. Attached Figure Description
[0013] Figure 1 A schematic flowchart illustrating a method for constructing a regulatory and standard knowledge base based on a large language model, provided for embodiments of this application; Figure 2 A schematic flowchart illustrating a semantic enhancement process provided for an embodiment of this application; Figure 3 A schematic diagram of a knowledge storage structure provided in an embodiment of this application; Figure 4 This is a schematic diagram of another knowledge storage structure provided in an embodiment of this application. Detailed Implementation
[0014] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the technical solutions in the embodiments of this application are clearly described. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art are within the scope of protection of this application.
[0015] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such terms can be used interchangeably where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0016] The steps described in this application and the flowcharts in the accompanying drawings are not necessarily strictly executed according to the step numbers; the execution order of the steps can be changed. Furthermore, certain steps can be omitted, multiple steps can be combined into one step, and / or one step can be broken down into multiple steps.
[0017] This specification provides a method for constructing a regulatory and standard knowledge base based on a large language model, and also relates to a device for constructing such a knowledge base, a computer device, a computer-readable storage medium, and a detection method. The aim is to achieve a dual-objective segmentation of regulatory texts, namely "hierarchical preservation + semantic integrity," to solve the problem of hierarchical semantic fragmentation. A multi-dimensional semantic enhancement mechanism is constructed to accurately capture the internal and cross-document reference relationships of regulatory texts, supplement keywords and hierarchical summaries, and improve semantic understanding capabilities. A hybrid storage architecture adapted to regulatory scenarios is designed to support multi-dimensional retrieval collaboration, meeting the security and efficiency requirements of localized compliance knowledge services. Ultimately, a structured, associative, and highly accurate regulatory and standard knowledge base is formed, supporting multiple application scenarios such as RAG dialogue assistants, intelligent agents, and conditional retrieval. The following detailed descriptions, in conjunction with the accompanying drawings and preferred embodiments, illustrate these methods.
[0018] Please see Figure 1 This application provides a method for constructing a regulatory and standard knowledge base based on a large language model, including: Step S1: Obtain multiple regulatory and standard documents and convert them into standardized text data.
[0019] This step is the preprocessing stage, mainly involving file selection and format conversion. Due to the diverse formats of regulatory and standard documents, multimodal recognition and conversion are necessary. Preferably, the Qwen-VL-OCR open-source model can be used to uniformly convert unstructured files into text files. Regular expressions are then used to clean up redundant characters, delimiters, line breaks, etc., resulting from format conversion in the text data, thus creating standardized text data.
[0020] Step S2: Based on the preset prompt word template, the text data is semantically segmented using a large language model; The prompt word template is used to guide the large language model to recognize the full-level directory structure of <chapter-section-article-clause-item-subject> in the text data, and to perform semantic block processing based on the full-level directory structure; the result generated by the semantic block processing includes: text blocks, block indexes, hierarchical path information and parent node indexes; the text blocks include at least: each level of directory in the full-level directory structure, and the text blocks may optionally include: the main text content corresponding to each level of directory.
[0021] This step enhances the semantic recognition capabilities of the language model by activating domain adaptation through customized prompts, achieving block processing with "hierarchical preservation + semantic integrity" without requiring model fine-tuning. Step S2 specifically includes: Step S21: Identify the directories at each level in the full-level directory structure of the text data; Step S22: Divide the main text content corresponding to each level of directory into blocks according to the principle of semantic integrity priority.
[0022] It is worth noting that some text blocks only include the table of contents because there is no corresponding text content for that level of table of contents; for tables of contents that have corresponding text content, such text blocks include both the tables of contents at each level of the full-level directory structure and the text content corresponding to each table of contents.
[0023] In some possible implementations, step S2 may further include: Step S23: For excessively long text units that exceed the maximum length threshold of the large model, perform secondary splitting by paragraph or punctuation, and configure sibling node indexes for the split text blocks to associate with the context during retrieval.
[0024] The semantic chunking process described above first identifies the full-level directory structure of the regulatory text and determines the hierarchical boundaries of the chunks. For the main text content corresponding to the directory, chunks are formed according to the principle of "semantic integrity first" to avoid semantic breaks caused by mechanical cutting. For extremely long chapters that exceed the maximum context length threshold of the selected large model, they are first split by paragraphs and punctuation marks, and then the sibling node indexes are marked to ensure that the context can be quickly associated during subsequent retrieval. The output format of the semantic chunking process is a JSON format structure, which includes information such as text chunk content, directory path, chunk index, and parent node index, clearly defining the hierarchical dependencies.
[0025] For example, a typical example of a prompt word is as follows:
[0026] An example of the effect of semantic block processing is as follows (taking "DB3402 / T 85-2024 Technical Specification for Artificial Intelligence-Assisted Cervical Cancer Cell Diagnosis" as an example):
[0027] In this process, due to the limitation of the context length of the large language model, text exceeding a certain threshold needs to be grouped using a sliding window approach. The following is a code example demonstrating the process of calling the large model to segment a legal standard fragment:
[0028] Step S3: Based on the results generated by the semantic segmentation process, entity relationships and keywords are extracted using the large language model, and a hierarchical summary is generated.
[0029] like Figure 2 As shown, this step aims to semantically enhance the segmented content, addressing the shortcomings of insufficient semantic association in existing technologies.
[0030] Furthermore, entity relationship extraction includes: By combining rule-based pre-screening with large language model extraction based on preset prompt word templates, three types of relationships are identified and extracted: inter-document citations, intra-document citations, and case-legal citations.
[0031] Among them, inter-document citations refer to specific chapters or entries of superior laws / other regulations; intra-document citations refer to different chapters of the same regulation; and case-regulation citations refer to the legal basis corresponding to the case.
[0032] In practice, the reference fragments are first pre-screened by rules (such as identifying reference sentences like "according to Article X of the XX Regulations") to reduce the frequency of large model calls and reduce resource consumption. Then, the large model is guided by customized prompt word templates to accurately extract the reference relationship and output a JSON result containing the chunk index (chunkId) of the original text and the full path of the referenced file (reference).
[0033] For example, one example of a prompt word is as follows:
[0034] Keyword extraction, preferably, is performed by using a large model to extract keywords from the segmented legal entries, also based on a preset prompt word template. In some possible implementations, keyword extraction can also be performed using word segmentation software. Although there are already many mature solutions for word segmentation software, using a large model for word segmentation has advantages over traditional Chinese word segmentation methods in terms of semantic understanding and generalization ability.
[0035] Here is an example of a keyword suggestion word for keyword extraction:
[0036] Furthermore, a hierarchical summary is generated, including: Based on the text content of the child nodes, the summary of the parent node is generated level by level through the large language model.
[0037] This application addresses the issue of regulatory catalog titles lacking substantive content or chapter entries being separated. It employs a "hierarchical aggregation" approach to generate hierarchical summaries. Based on the text content of child nodes, a larger model is used to generate summaries for parent nodes, ultimately forming a multi-layered summary system at the document, catalog, and text block levels. This ensures that the summaries accurately reflect the core content of the corresponding level, supporting rapid understanding of the regulatory logic.
[0038] In some possible implementations, the results of segmented content and semantic enhancement can be manually reviewed, including verifying the accuracy of hierarchical relationships, the completeness of citation relationships, and the precision of keywords and summaries; and error cases can be recorded to optimize the prompt word template and rule pre-screening logic, forming a closed-loop optimization mechanism of "model output - manual review - algorithm iteration".
[0039] Step S4: Construct a file index based on the entity relationship, the keywords, and the hierarchical summary; store the text blocks, block indexes, hierarchical path information, parent node indexes, and file indexes into the knowledge base according to a predefined knowledge storage structure; The document index includes at least a regulatory and standard document index and a directory index; The knowledge storage structure includes at least an index area, an entry text area, and a case area.
[0040] Furthermore, the index area stores the file index in a tree structure; The entry text area stores the text block, as well as its corresponding block index, hierarchical path information, and parent node index; The case area stores case texts associated with legal provisions.
[0041] In this application, such as Figure 3-4 As shown, a three-tiered, collaborative knowledge storage structure is defined, consisting of an index area, an entry text area, and a case study area. The functions of each level are precisely matched to the application requirements of regulations, forming a logically unified knowledge base system. 1. The index area stores the names of regulations and standards and their directory hierarchy in a tree structure. It is divided into a file-level index for locating regulation names and a directory-level index for parsing the entire directory structure within a file, supporting quick location of target regulations and chapters.
[0042] 2. The entry text area stores the main text of regulations and standards in an entry-based manner, preserving the hierarchical structure and boundaries of chapters and entries. After splitting excessively long chapters, sibling node indexes are marked to facilitate the connection of context during retrieval.
[0043] Text segmentation is the core content of this application's knowledge base and also the largest part of the data. Through a large model, the semantic relationships within the chapters of the regulations and standards are preserved. Within each text block, the hierarchical structure and boundaries of the chapter entries in the regulations and standards documents are preserved, provided the character length does not exceed the segmentation threshold. For chapters with excessively long content, their chapter directory hierarchy is supplemented, and blocks are formed according to paragraphs and punctuation marks, with the indices of their sibling nodes marked. During subsequent retrieval, the context can be quickly found based on the indices of their sibling nodes, enabling joint reasoning. For text blocks containing only titles, the large model is used to extract and merge summaries from the content of their lower-level nodes, generating a summary at that level.
[0044] 3. The case study area stores the application case texts of the corresponding regulations, which are used to assist in verifying the implementation of the regulations and to achieve the semantic association between "regulations and cases".
[0045] Thus, the index, entry text, and case studies are linked together based on semantic relationships. These three parts form a hierarchical structure, with the text content gradually becoming richer. This hybrid storage method of "structured database + text vector library" not only directly supports text vector-based retrieval but also better supports top-down retrieval methods, maximizing the hierarchical and structural characteristics of regulatory and standard texts.
[0046] Furthermore, the data elements of the regulatory standard document index include: document name, hierarchical summary at the file level, keywords, original file path, and number of cases.
[0047] Specifically, this level can be viewed as a directory index of regulatory and standard documents. An example of the data element composition of a regulatory and standard document index is as follows:
[0048] Furthermore, the data elements of the directory index include: document name, current directory name, global path, directory-level summary, keywords, intra-chapter references, and cross-file references.
[0049] Specifically, this level of node defines the document's table of contents. While a typical document might only display the first level or a few levels of chapter headings, this level stores the entire document's table of contents to support subsequent searches. Additionally, by extracting content from document chapters, corresponding reference relationships are marked, including intra-document cross-references and cross-document references. An example of the data element composition of a table of contents index is as follows:
[0050] Based on the above solution, this application addresses the unique attributes of regulatory standard texts, overcomes the technical limitations of the existing RAG model, and forms a three-in-one technical solution of "blocking-enhancement-storage". The key points are as follows: 1. Adapting to the unique "chapter-section-article-clause" hierarchical structure of legal texts, and without establishing a semantic dependency completion mechanism for "parent node-child node," this innovative semantic segmentation scheme for legal texts adopts a dual-objective approach of "hierarchical preservation + semantic integrity." Unlike the mechanical logic of existing character segmentation and general semantic segmentation, it activates the legal domain adaptability of the large model through customized prompts, achieving a balance between preserving the hierarchical relationship of "chapter-section-article-clause" and ensuring the semantic integrity of clauses without fine-tuning the model. Simultaneously, it adapts to multimodal file formats, resolving the semantic fragmentation problem of extremely long chapters and providing high-quality knowledge units for subsequent retrieval.
[0051] 2. For cross-references in regulatory texts, including intra-document citations, cross-document citations, and case-regulatory citations, a correlation extraction mechanism is designed, and an index construction mechanism integrating multi-dimensional semantic enhancement is proposed. Breaking away from the traditional index's reliance on keyword matching, this mechanism deeply integrates four methods: "citation relationship extraction, keyword extraction, hierarchical automatic summarization, and content association completion." Through a hybrid strategy of "rule pre-screening + large-scale model extraction," it accurately captures the complex semantic relationships in regulatory texts, forming a "semantically enriched index." This index integrates hierarchical features and citation relationships of the regulatory text, addressing the shortcomings of existing indexes in terms of insufficient semantic information.
[0052] 3. Design a three-tiered hybrid storage architecture adapted to regulatory scenarios. An innovative storage structure is implemented, linking the "index area - entry text area - case area." This differentiates the application needs of different data types within the regulatory text, such as indexes, main text, and cases, ensuring each level's functionality precisely matches regulatory retrieval and application requirements. A tree-structured index supports rapid location, while the hierarchical structure of entry text blocks and sibling node markers supports contextual association. The case area enables linked verification of "regulations and cases." The hybrid storage mode balances retrieval efficiency and semantic accuracy, meeting diverse needs such as hierarchical retrieval and cross-file retrieval.
[0053] This application has the following benefits: (1) Significantly improves the relevance and accuracy of search results. Compared with traditional segmentation methods, the "semantic segmentation + multi-dimensional semantic enhancement" scheme of this invention greatly optimizes the core search indicators, especially in the scenario of "semantic query that requires understanding the context relationship", which can accurately and efficiently locate the text segment and avoid the search bias caused by semantic breakage in traditional segmentation.
[0054] (2) Ensure the integrity and relevance of legal knowledge, effectively solve the core pain points in the construction of legal standard knowledge base, retain the integrity of professional terms through hierarchical semantic block division; eliminate the understanding obstacles caused by "blank nodes" through reference relationship extraction; support multi-law collaborative retrieval through cross-file association index, and meet the needs of global overall analysis.
[0055] (3) Adapt to localized private compliance knowledge service needs, realize offline knowledge base construction based on large model, ensure the data security of legal documents within the enterprise / organization, reduce manual construction costs through automated block division and semantic enhancement, and at the same time, the architecture can flexibly connect to RAG dialogue assistant, intelligent agent, small model application scenarios, etc., to provide users with a one-stop legal knowledge service of "semantic understanding and accurate retrieval".
[0056] Furthermore, the indexing of its knowledge base generally relies on keyword matching or a single semantic vector, resulting in poor matching accuracy for multi-dimensional information such as hierarchical features and citation relationships of regulatory texts.
[0057] Corresponding to the above-described embodiment of the method for constructing a regulatory and standard knowledge base based on a large language model, this application embodiment provides a retrieval method, including: Receive natural language search commands; In response to the natural language retrieval command, a retrieval is performed based on the legal and standard knowledge base constructed using the above method, and an answer result is generated.
[0058] The above retrieval method implements the steps and processes of the above-described embodiment of the method for constructing a legal and standard knowledge base based on a large language model, and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0059] Corresponding to the above-described embodiment of the method for constructing a legal and standard knowledge base based on a large language model, this application embodiment provides an apparatus for constructing a legal and standard knowledge base based on a large language model, including: The document acquisition module is used to acquire multiple regulatory and standard documents and convert them into standardized text data; The semantic segmentation processing module is used to perform semantic segmentation processing on the text data based on a preset prompt word template and a large language model. The prompt word template is used to guide the large language model to recognize the full-level directory structure of <chapter-section-article-clause-item-subject> in the text data, and to perform semantic block processing based on the full-level directory structure; the result generated by the semantic block processing includes: text blocks, block indexes, hierarchical path information, and parent node indexes; the text block includes at least: each level of directory in the full-level directory structure, and optionally includes: the main text content corresponding to each level of directory; The semantic enhancement module is used to extract entity relationships and keywords based on the results generated by the semantic segmentation process, and to generate hierarchical summaries using the large language model. The knowledge storage module is used to construct a file index based on the entity relationship, the keywords, and the hierarchical summary; and to store the text blocks, block indexes, hierarchical path information, parent node indexes, and file indexes into the knowledge base according to a predefined knowledge storage structure. The document index includes at least a regulatory and standard document index and a directory index; The knowledge storage structure includes at least an index area, an entry text area, and a case area.
[0060] Furthermore, the semantic segmentation processing module is specifically used for: Identify each level of the directory structure within the full-level directory structure of the text data; The main text content corresponding to each level of directory is divided into blocks according to the principle of semantic integrity.
[0061] Furthermore, the semantic segmentation processing module is specifically used for: For excessively long text units that exceed the maximum length threshold of the large model, secondary splitting is performed by paragraph or punctuation, and sibling node indexes are configured for the split text blocks to associate with the context during retrieval.
[0062] Furthermore, the entity relationship extraction includes: By combining rule-based pre-screening with large language model extraction based on preset prompt word templates, three types of relationships are identified and extracted: inter-document citations, intra-document citations, and case-legal citations.
[0063] Furthermore, the generation of hierarchical summaries includes: Based on the text content of the child nodes, the summary of the parent node is generated level by level through the large language model.
[0064] Furthermore, the index area stores the file index in a tree structure; The entry text area stores the text block, as well as its corresponding block index, hierarchical path information, and parent node index; The case area stores case texts associated with legal provisions.
[0065] The above-described apparatus for constructing a legal and standard knowledge base based on a large language model implements the steps and processes of the above-described method for constructing a legal and standard knowledge base based on a large language model, and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0066] Corresponding to the above embodiments of the method for constructing a regulatory and standard knowledge base based on a large language model, this application provides an electronic device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the steps and processes of the above embodiments of the method for constructing a regulatory and standard knowledge base based on a large language model, and achieves the same technical effect. To avoid repetition, it will not be described again here.
[0067] Memory can be used to store software programs and various data. Memory can primarily include a first storage area for storing programs or instructions and a second storage area for storing data. The first storage area can store the operating system, application programs or instructions required for at least one function (such as sound playback, image playback, etc.). Furthermore, memory can include volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDRSDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (Synchlink DRAM, SLDRAM), and direct memory bus RAM (DRRAM). The memory in the embodiments of this application includes, but is not limited to, these and any other suitable types of memory.
[0068] The processor may include one or more processing units; optionally, the processor integrates an application processor and a modem processor, wherein the application processor mainly handles operations related to the operating system, user interface, and applications, while the modem processor mainly handles wireless communication signals, such as a baseband processor. It is understood that the aforementioned modem processor may also not be integrated into the processor.
[0069] Corresponding to the above embodiments of the method for constructing a legal and standard knowledge base based on a large language model, this application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the steps and processes of the above embodiments of the method for constructing a legal and standard knowledge base based on a large language model, and achieve the same technical effect. To avoid repetition, these will not be described again here.
[0070] The processor is the processor in the electronic device described in the above embodiments of this application. The readable storage medium includes a computer-readable storage medium, such as a computer read-only memory (ROM), random access memory (RAM), a magnetic disk, or an optical disk.
[0071] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0072] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0073] It is understood that the embodiments of this application have been described above in conjunction with the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. As those skilled in the art will know, various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the invention. Furthermore, those skilled in the art, under the guidance or instruction of this application, can modify these features and embodiments to adapt to specific situations and materials without departing from the spirit and scope of the invention. Therefore, this invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the protection scope of this invention.
Claims
1. A method for constructing a legal and standard knowledge base based on a large language model, characterized in that, include: Obtain multiple regulatory and standard documents and convert them into standardized text data; Based on a preset prompt word template, the text data is semantically segmented using a large language model; The prompt word template is used to guide the large language model to recognize the full-level directory structure of <chapter-section-article-clause-item-item> in the text data, and to perform semantic block processing based on the full-level directory structure; The result generated by the semantic block processing includes: text blocks, block indexes, hierarchical path information, and parent node indexes; the text blocks include at least: each level of the directory in the full-level directory structure, and optionally include: the main text content corresponding to each level of the directory; Based on the results generated by the semantic segmentation process, entity relationships and keywords are extracted using the large language model, and a hierarchical summary is generated. A file index is constructed based on the entity relationships, the keywords, and the hierarchical summary; the text blocks, block indexes, hierarchical path information, parent node indexes, and file indexes are stored in the knowledge base according to a predefined knowledge storage structure. The document index includes at least a regulatory and standard document index and a directory index; The knowledge storage structure includes at least an index area, an entry text area, and a case area.
2. The method for constructing a legal and standard knowledge base based on a large language model according to claim 1, characterized in that, The aforementioned semantic segmentation of the text data based on the preset prompt word template utilizes a large language model, including: Identify each level of the directory structure within the full-level directory structure of the text data; The main text content corresponding to each level of directory is divided into blocks according to the principle of semantic integrity.
3. The method for constructing a legal and standard knowledge base based on a large language model according to claim 2, characterized in that, The method of using a large language model to perform semantic segmentation of the text data based on a preset prompt word template also includes: For excessively long text units that exceed the maximum length threshold of the large model, secondary splitting is performed by paragraph or punctuation, and sibling node indexes are configured for the split text blocks to associate with the context during retrieval.
4. The method for constructing a legal and standard knowledge base based on a large language model according to claim 1, characterized in that, The entity relationship extraction includes: By combining rule-based pre-screening with large language model extraction based on preset prompt word templates, three types of relationships are identified and extracted: inter-document citations, intra-document citations, and case-legal citations.
5. The method for constructing a legal and standard knowledge base based on a large language model according to claim 1, characterized in that, The generation of hierarchical summaries includes: Based on the text content of the child nodes, the summary of the parent node is generated level by level through the large language model.
6. The method for constructing a legal and standard knowledge base based on a large language model according to claim 1, characterized in that, The index area stores the file index in a tree structure; The entry text area stores the text block, as well as its corresponding block index, hierarchical path information, and parent node index; The case area stores case texts associated with legal provisions.
7. A device for constructing a legal and standard knowledge base based on a large language model, characterized in that, include: The document acquisition module is used to acquire multiple regulatory and standard documents and convert them into standardized text data; The semantic segmentation processing module is used to perform semantic segmentation processing on the text data based on a preset prompt word template and a large language model. The prompt word template is used to guide the large language model to recognize the full-level directory structure of <chapter-section-article-clause-item-item> in the text data, and to perform semantic block processing based on the full-level directory structure; The result generated by the semantic block processing includes: text blocks, block indexes, hierarchical path information, and parent node indexes; the text blocks include at least: each level of the directory in the full-level directory structure, and optionally include: the main text content corresponding to each level of the directory; The semantic enhancement module is used to extract entity relationships and keywords based on the results generated by the semantic segmentation process, and to generate hierarchical summaries using the large language model. The knowledge storage module is used to construct a file index based on the entity relationship, the keywords, and the hierarchical summary; and to store the text blocks, block indexes, hierarchical path information, parent node indexes, and file indexes into the knowledge base according to a predefined knowledge storage structure. The document index includes at least a regulatory and standard document index and a directory index; The knowledge storage structure includes at least an index area, an entry text area, and a case area.
8. A retrieval method, characterized in that, include: Receive natural language search commands; In response to the natural language retrieval command, a retrieval is performed based on a regulatory and standard knowledge base constructed using the method described in any one of claims 1-6, and an answer result is generated.
9. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the method for constructing a regulatory standard knowledge base based on a large language model as described in any one of claims 1 to 6.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions that, when executed by a processor, implement the steps of the method for constructing a regulatory standard knowledge base based on a large language model as described in any one of claims 1 to 6.
