Graph structure-based hierarchical retrieval method and system and storage medium
Through a hierarchical search method based on graph structure, the document data graph is structured and hybrid search technology is adopted, which solves the problem of low correlation and redundancy in large-scale unstructured document data, and achieves efficient and accurate information retrieval effect.
Patent Information
- Application Number
- CN202411173612.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-20
AI Technical Summary
When traditional information retrieval methods deal with large-scale unstructured document data, there are problems such as low relevance and redundancy in search results, especially in complex scenarios, which are difficult to achieve accurate information recall.
Using a hierarchical search method based on graph structure, document data is split into graph structures by blocks, searching through mixed semantic similarity and key phrases, filtering layer by layer from top to bottom, and constructing a structured document graph database and vector database to realize Efficient and accurate retrieval of user input content.
The data magnitude in the initial screening stage of the search has been effectively reduced, the accuracy and completeness of information retrieval is improved, and the comprehensive acquisition of related articles has been ensured.
Smart Images

Figure CN119166829A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of natural language processing and analysis, and in particular to a hierarchical retrieval method, system and storage medium based on a graph structure. Background Art
[0002] Information retrieval is an important means of obtaining text data related to the text to be retrieved. It is a retrieval and analysis method for text data with complex structure, large volume and high dimension. It aims to quickly and accurately filter out information related to user needs from a large amount of information according to user needs. At present, large language models are developing rapidly, but they themselves have the problem of generating illusions of results. In order to enhance the authenticity of their generated results, RAG (retrieval-augmented generation) has become the mainstream method, that is, to obtain relevant external knowledge through user demand retrieval and generate relevant content in combination with large models. The traditional RAG method is relatively good at retrieval tasks in specific fields, but it has shortcomings in complex scenarios and large volumes. The retrieved content is not highly relevant and redundant, resulting in inaccurate answers generated in the reasoning stage of large models. Therefore, it is of great research value to establish an efficient and accurate information retrieval method based on open source data in complex scenarios.
[0003] Traditional information retrieval steps include keyword-based retrieval, semantic similarity-based retrieval, probability-based retrieval, hybrid retrieval, etc., which have certain limitations in processing large-scale unstructured document data. For example, vector-based semantic similarity retrieval, when processing large-scale unstructured document data, first divides the document into blocks and vectorizes it, and the data volume increases exponentially. The retrieval stage is generally divided into preliminary screening and fine sorting. However, in the preliminary screening stage, due to the strong coupling between sentences, paragraphs, and documents in the document, and the large data base caused by block division, it is impossible to fully recall or recall more irrelevant documents, so that in the large model reasoning stage, the external knowledge is incomplete, irrelevant, and redundant, resulting in inaccurate results. Summary of the invention
[0004] In view of the problems existing in the prior art, a hierarchical retrieval method, system and storage medium based on graph structure are provided. Based on the graph structuring of document data, the document data is split into blocks, and the title, abstract and document block are respectively connected from top to bottom as nodes to form an entity group of graph structure; based on the constructed document graph structure database, semantic similarity and key phrase hybrid retrieval are performed, and a hierarchical top-down retrieval is adopted to screen layer by layer to achieve accurate and complete acquisition of relevant articles.
[0005] The first aspect of the present invention proposes a hierarchical retrieval method based on a graph structure, comprising:
[0006] The source document is segmented and instantiated into title-level entities, summary-level entities, and document-block-level entities, and key entities in the document-block entities are extracted as attribute information of each title-level entity, summary-level entity, and document-block-level entity;
[0007] The title-level entities, summary-level entities, and document-block-level entities are connected in a directed manner from top to bottom and in the same level by similar association, thus constructing a document graph structured database.
[0008] Vectorize the title-level entities, summary-level entities, and document-block-level entities, and build semantic-based vector databases respectively;
[0009] Based on the constructed graph-structured database and vector database, a top-down hierarchical retrieval method is used to realize the retrieval of user input content.
[0010] As a preferred solution, the instantiation method of the title-level entity includes:
[0011] The source document is segmented into paragraphs, and a prompt learning method is used based on a large language model to generate a title for each paragraph to form a title-level entity.
[0012] As a preferred solution, the instantiation method of the document block-level entity includes:
[0013] After segmenting the source document by paragraphs, each paragraph is split by delimiters to obtain sentences divided by delimiters;
[0014] The similarity between adjacent sentences is calculated, and adjacent sentences with similarity greater than a preset threshold are merged into a group as a document block to form a document block-level entity; among them, the document blocks segmented from the same paragraph are regarded as an entity group.
[0015] As a preferred solution, the instantiation method of the summary-level entity includes:
[0016] Based on the large language model, a prompt learning method is used to summarize the document block entity groups to form summary-level entities.
[0017] As a preferred solution, the key entities in the document block entity are extracted as attribute information of each title-level entity, summary-level entity, and document block-level entity, specifically including:
[0018] The key entities in each document block-level entity are identified and acquired, and the attribute information of the title-level entity, summary-level entity, and document block-level entity is managed and stored, and the attribute information is used for keyword retrieval index; wherein the key entities include time, place, person, and organization.
[0019] As a preferred solution, the specific method for constructing the document graph structured database includes:
[0020] The density clustering model is used to cluster summary-level entities, and the semantic similarity method is used to calculate the similarity value between two summary-level entities of the same type;
[0021] Directed connections are made to the title-level entities, summary-level entities, and document-block-level entities. Each entity uses the attribute information it contains as a keyword search index. The title-level entity is used as the head node of the document graph structure, the summary-level entity is used as the middle node of the document graph structure, and the document-block-level entity is used as the tail node of the document graph structure.
[0022] The similarity values between summary-level entities are used as relations to associate summary-level entities;
[0023] Complete the construction of document graph structured database.
[0024] As a preferred solution, the top-down hierarchical search method is used to implement the search of the user input content, which specifically includes:
[0025] Vectorize the user input content based on the word embedding model and extract the key entity information contained in it;
[0026] A hybrid search method of keywords and text semantics is used to perform similarity matching on title-level entities, and abstract-level entities associated with title-level entities that meet the conditions are obtained as candidate sets for subsequent retrieval;
[0027] A hybrid search method of keywords and text semantics is used to perform similarity matching on the summary-level entities in the candidate set, and the document block-level entities associated with the summary-level entities that meet the conditions are obtained as the candidate set for subsequent retrieval;
[0028] The hybrid retrieval method of keywords and text semantics is used to perform similarity matching on the document block-level entities in the candidate collection to obtain text data related to the user input content.
[0029] As a preferred solution, the method of hybrid retrieval of keywords and text semantics specifically includes:
[0030] Get similar results of text semantic retrieval;
[0031] Get keyword search results;
[0032] The text semantic search similarity results and the keyword search results are weighted to obtain the mixed search similarity results; wherein the weight of the text semantic search similarity results is greater than the weight of the keyword search results;
[0033] Entities whose hybrid retrieval similarity results are greater than the preset threshold are considered to meet the conditions.
[0034] A second aspect of the present invention proposes a system including a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executes the hierarchical retrieval method based on the graph structure as described in the first aspect.
[0035] The third aspect of the present invention proposes a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, are used to implement a process corresponding to the graph-structure-based hierarchical retrieval method described in the first aspect.
[0036] Compared with the existing technology, the beneficial effects of adopting the above technical scheme are: first, based on document segmentation, instantiation, clustering and other methods, the structured representation of the document graph is realized, which provides effective data support for subsequent information retrieval; second, based on the constructed document graph structured data, a hierarchical retrieval method is adopted, which greatly limits the amount of data to be retrieved in the initial screening stage of retrieval, narrows the scope of articles to be recalled, and improves the accuracy and completeness of information retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 This is a flow chart of the graph-based hierarchical retrieval method proposed in the present invention.
[0038] Figure 2 The diagram is a schematic diagram of constructing a document graph structured database in one embodiment of the present invention.
[0039] Figure 3 Schematic diagram of hierarchical retrieval process in one embodiment of the present invention. DETAILED DESCRIPTION
[0040] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar modules or modules with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be construed as limitations on the present application. On the contrary, the embodiments of the present application include all changes, modifications and equivalents that fall within the spirit and connotation of the appended claims.
[0041] In order to retrieve relevant content efficiently and accurately, the embodiment of the present invention proposes a hierarchical retrieval method based on graph structure, which divides documents into different entity groups with related relationships, generates titles and abstracts for each group, and extracts keywords, so as to structure the unstructured document data graph, and then implements relevant text retrieval in a hierarchical top-down manner. Please refer to Figure 1 , the specific plan is as follows:
[0042] Step 1: Segment the source document and instantiate title-level entities, summary-level entities, and document block-level entity representations, and extract key entities from the document block entities as attribute information of each title-level entity, summary-level entity, and document block-level entity.
[0043] Please refer to Figure 2 Before implementing the hierarchical retrieval method proposed in this embodiment, it is necessary to instantiate the document data and form a graph structure for entity association. In this embodiment, it mainly includes the generation of title-level entities, abstract-level entities, and document-block-level entities.
[0044] For title-level entities, in this embodiment, the source document is segmented into paragraphs, and a prompt learning method is used based on a large language model to generate a title for each paragraph to form a title-level entity. For example, there are n articles to be processed, which include t paragraphs after segmentation. Based on a large language model, a prompt learning method is used to generate titles for the source document paragraphs to form t title entity sets T = [T1, T2...T n ].
[0045] For document block-level entities, in this embodiment, after the source document is segmented into paragraphs, each paragraph is split by a separator to obtain sentences divided by the separator. In one embodiment, the separators include. ;? !, etc.
[0046] After completing the sentence division, the similarity between adjacent sentences is calculated, and the adjacent sentences with similarity greater than the preset threshold are merged into a group as a document block to form a document block level entity. Finally, the text block entity set N = [N1, N2...N k ]; the document blocks segmented from the same paragraph are regarded as an entity group.
[0047] For the title-level entity, in this embodiment, the document block entity group is summarized by using the prompt learning method based on the large language model to form a summary-level entity, and finally the summary-level entity set S = [S1, S2...S k ].
[0048] Keywords are an important part of information retrieval. In this embodiment, after completing the instantiation of entities at all levels, key entities such as "time, place, person, organization" in each document block entity are identified and obtained, and managed and stored as attribute information of each title-level entity, summary-level entity, and document block-level entity. This part is the keyword retrieval index, which can be expressed as attr.
[0049] Step 2: Use a top-down, same-level similarity association approach to connect the title-level entities, summary-level entities, and document-block-level entities in a directed manner to build a document graph structured database.
[0050] Please continue to refer to Figure 2 Before constructing the document graph structured database, it is also necessary to establish the association relationship between the summary level nodes. In this embodiment, the summary level nodes are clustered based on the density clustering model (HDBSCAN), and the cosine similarity values between the same class are calculated using the semantic similarity method. Used for association of related summary-level nodes.
[0051] Specifically, this embodiment adopts a top-down, same-level similarity association method to establish a document graph structured database, and connects the obtained title-level entities, summary-level entities, and document block-level entities in a directed manner according to the T:{attr}->S:{attr}->N:{attr} method, wherein the identified key entities such as "time, place, person, and organization" are extracted as attribute information of the title-level entities, summary-level entities, and document block-level entities. After the connection is completed, the summary-level node similarity value calculated by clustering is used as the relationship for entity association, thereby realizing the structuring of the document data graph.
[0052] Step 3: Vectorize the title-level entities, summary-level entities, and document-block-level entities, and build semantic-based vector databases respectively.
[0053] In this embodiment, the title T, summary S, and document block N are respectively vectorized based on the bge word embedding model.
[0054] Step 4: Based on the constructed graph structured database and vector database, a top-down hierarchical search method is used to realize the retrieval of user input content.
[0055] For details, please refer to Figure 3 The hierarchical search method proposed in this embodiment is as follows:
[0056] (1) Vectorize the user input content Q based on the word embedding model and extract the key entity information contained in it;
[0057] (2) At the title level, a hybrid search method of keywords and text semantics is used to perform similarity matching on the title level entities, and the summary level entities S = [S1, S2...S t ] as a candidate set for subsequent retrieval;
[0058] (3) At the summary level, a hybrid search method of keywords and text semantics is used to search for summary-level entities S = [S1, S2...S t ] to perform similarity matching and obtain the document block-level entity N=[N1,N2...N t] as a candidate set for subsequent retrieval;
[0059] (4) At the document block level, a hybrid search method of keywords and text semantics is used to search for document block-level entities N = [N1, N2...N t ] performs similarity matching to obtain text data related to the user input content.
[0060] Among them, the methods of mixed retrieval of keywords and text semantics include:
[0061] Separately obtain text semantic search similarity results and obtain keyword search results, and weight the text semantic search similarity results and keyword search results to obtain a hybrid search similarity result. In this embodiment, the hybrid search similarity result can be expressed as Among them, α1 is the text semantic retrieval similarity result, ω1 is its weight value, α2 is the keyword retrieval result, ω2 is its weight value, and ω1>ω2. t Entities that are larger than the set threshold are considered to meet the conditions.
[0062] It should be noted that the search formula is performed using a hybrid search method of keywords and text semantics at the title level, abstract level and document block level, and the threshold for comparing similar results with the hybrid search can be adjusted according to needs.
[0063] The hierarchical retrieval method proposed in this embodiment can greatly limit the number of texts in the library to be searched in the initial screening stage of the search. At the same time, through clustering and other methods, the association between similar document blocks can be achieved, narrowing the search scope of the articles to be recalled, thereby achieving comprehensive and accurate acquisition of relevant articles.
[0064] Furthermore, this embodiment also proposes a system, including a memory and a processor, wherein the memory stores a computer program corresponding to the aforementioned graph-structure-based hierarchical retrieval method that can be loaded and executed by the processor.
[0065] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer readable medium, and the computer program includes a program code for executing the method shown in the flowchart.
[0066] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0067] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0068] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0069] As another aspect, the present application also provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the hierarchical retrieval method based on the graph structure described in the above embodiment.
[0070] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently without being assembled into the electronic device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by an electronic device, the electronic device implements the hierarchical retrieval method based on the graph structure described in the above embodiment.
[0071] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0072] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0073] For those skilled in the art, the specific meanings of the above terms in the present invention can be understood in specific situations; the drawings in the embodiments are used to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.
[0074] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A hierarchical retrieval method based on graph structure, characterized in that: include: The source document is segmented and instantiated into title-level entities, summary-level entities, and document-block-level entities, and key entities in the document-block entities are extracted as attribute information of each title-level entity, summary-level entity, and document-block-level entity; Using a top-down, same-level similarity association approach, we connect the title-level entities, summary-level entities, and document-block-level entities in a directed manner to build a document graph structured database. Vectorize title-level entities, summary-level entities, and document-block-level entities, and construct semantic-based vector databases for each. Based on the constructed graph-structured database and vector database, a top-down hierarchical retrieval method is used to realize the retrieval of user input content.
2. The hierarchical retrieval method based on graph structure according to claim 1, characterized in that: The instantiation method of the title-level entity includes: The source document is segmented into paragraphs, and a prompt learning method is used based on a large language model to generate a title for each paragraph to form a title-level entity.
3. The hierarchical retrieval method based on graph structure according to claim 1 or 2, characterized in that: The instantiation method of the document block-level entity includes: After segmenting the source document by paragraphs, each paragraph is split by delimiters to obtain sentences divided by delimiters; Calculate the similarity between adjacent sentences, merge adjacent sentences with similarity greater than a preset threshold into a group as a document block, and form a document block-level entity; among them, the document blocks segmented from the same paragraph are regarded as an entity group.
4. The hierarchical retrieval method based on graph structure according to claim 1, characterized in that: The instantiation method of the summary-level entity includes: Based on the large language model, a prompt learning method is used to summarize the document block entity groups to form summary-level entities.
5. The hierarchical retrieval method based on graph structure according to claim 1, characterized in that: The key entities in the document block entity are extracted as attribute information of each title-level entity, summary-level entity, and document block-level entity, specifically including: The key entities in each document block-level entity are identified and acquired, and the attribute information of the title-level entity, summary-level entity, and document block-level entity is managed and stored. The attribute information is used for keyword retrieval indexing; wherein, the key entities include time, place, person, and organization.
6. The hierarchical retrieval method based on graph structure according to claim 1, characterized in that: The specific method for constructing the document graph structured database includes: The density clustering model is used to cluster summary-level entities, and the semantic similarity method is used to calculate the similarity between two summary-level entities of the same type. Directed connections are made to title-level entities, summary-level entities, and document-block-level entities. The attribute information contained in each entity is used as a keyword search index. The title-level entity is used as the head node of the document graph structure, the summary-level entity is used as the middle node of the document graph structure, and the document-block-level entity is used as the tail node of the document graph structure. The similarity values between summary-level entities are used as relationships to associate summary-level entities; Complete the construction of the document graph structured database.
7. The hierarchical retrieval method based on graph structure according to claim 1, characterized in that: The top-down hierarchical search method is used to retrieve the user input content, specifically including: Vectorize the user input content based on the word embedding model and extract the key entity information contained in it; A hybrid search method of keywords and text semantics is used to perform similarity matching on title-level entities, and abstract-level entities associated with qualified title-level entities are obtained as candidate sets for subsequent retrieval. A hybrid search method of keywords and text semantics is used to perform similarity matching on the summary-level entities in the candidate set, and the document block-level entities associated with the summary-level entities that meet the conditions are obtained as the candidate set for subsequent retrieval; A hybrid retrieval method of keywords and text semantics is used to perform similarity matching on the document block-level entities in the candidate collection to obtain text data related to the user input content.
8. The hierarchical retrieval method based on graph structure according to claim 7, characterized in that: The method of hybrid retrieval of keywords and text semantics specifically includes: Get similar results of text semantic retrieval; Get keyword search results; The text semantic search similarity results and the keyword search results are weighted to obtain the mixed search similarity results; wherein, the weight of the text semantic search similarity results is greater than the weight of the keyword search results; Entities whose hybrid retrieval similarity results are greater than the preset threshold are considered to meet the conditions.
9. A system, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program that can be loaded by the processor and executed according to any one of claims 1 to 8 and corresponding to the hierarchical retrieval method based on graph structure.
10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, they are used to implement a process corresponding to the graph-structure-based hierarchical retrieval method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Text vectorization storage method and device, text vectorization retrieval method and device and computer equipment
CN115146027A
Text retrieval method and device, electronic equipment and storage medium
CN118312587A
Cited By
Long text retrieval method and device based on graph structure and computer equipment
CN119961447A
Industrial document intelligent retrieval method and system based on large model
CN120744081A
Industrial document intelligent retrieval method and system based on large model
CN120744081B
Report filling-in-place unit identification method and device based on multi-level clustering
CN121117212A
Book semantic retrieval method and device based on intention recognition and electronic equipment
CN121188143A
