Knowledge graph-based retrieval method and related apparatuses

By constructing a knowledge graph-based retrieval method, entity relationships are automatically extracted and combined with vector data, solving the accuracy problem of traditional methods when processing unstructured documents, and achieving efficient and accurate text retrieval results generation.

CN122332571APending Publication Date: 2026-07-03GUANGDONG PHNIX ECO ENERGY SOLUTION
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
GUANGDONG PHNIX ECO ENERGY SOLUTION
Filing Date
2026-03-20
Publication Date
2026-07-03

Smart Images

  • Figure CN122332571A_ABST
    Figure CN122332571A_ABST
Patent Text Reader

Abstract

This application relates to a knowledge graph-based retrieval method and related apparatus, comprising: acquiring raw text data; extracting entities from the raw text data and identifying relationships between entities using a first language model to obtain triplet data and descriptive text data corresponding to each entity; constructing a knowledge graph and target vector data; performing similarity retrieval in the knowledge graph and target vector data based on first text information input by the user to obtain at least one second text information; and inputting the second text information into a second language model so that the second language model outputs text retrieval results based on the second text information. The solution provided in this application, by automatically extracting entity relationships to construct a knowledge graph and combining it with vector data for retrieval, can improve the efficiency of knowledge graph construction and retrieval accuracy, reduce model illusions, and improve the accuracy of text retrieval results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a knowledge graph-based retrieval method and related apparatus. Background Technology

[0002] As the digitization of text documents becomes more widespread within enterprises, the number of electronic documents continues to increase over time. In particular, these documents are often in non-standard, complex, and unstructured formats, making it impossible to directly apply traditional database query methods. This hinders internal personnel from quickly locating the required documents and from directly obtaining the key information needed within them.

[0003] Traditional methods rely on manually defining entity types and relational patterns. This approach has significantly insufficient generalization ability when faced with texts with highly diverse linguistic expressions. Furthermore, when using large language models for retrieval, the lack of factual knowledge in these models can lead to illusions, resulting in the generation of incorrect or untrue answers. Consequently, large language models are unable to provide the required key information based on the matched text, thus increasing the difficulty for users to filter and extract effective information. Summary of the Invention

[0004] To address or partially address the problems existing in related technologies, this application provides a knowledge graph-based retrieval method and related apparatus. By automatically extracting entity relationships to construct a knowledge graph and combining it with vector data for retrieval, this method can improve the efficiency of knowledge graph construction and retrieval accuracy, reduce model illusions, and improve the accuracy of text retrieval results.

[0005] This application provides a knowledge graph-based retrieval method, comprising: acquiring original text data; extracting entities from the original text data and identifying relationships between the entities using a first language model to obtain triple data and descriptive text data corresponding to each entity; constructing a knowledge graph and target vector data based on the original text data, the triple data, and the descriptive text data; wherein the knowledge graph is composed of triple data as nodes, and the target vector data is composed of vectorized versions of the original text data and the descriptive text data; performing a similarity search on the knowledge graph and the target vector data based on first text information input by a user to obtain at least one second text information; and inputting the second text information into a second language model so that the second language model outputs text retrieval results based on the second text information.

[0006] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of constructing a knowledge graph and target vector data based on the original text data, the triple data, and the descriptive text data includes: storing entities in the triple data as nodes and the relationships between the entities as connecting edges in a preset graph database to construct the knowledge graph; and vectorizing the original text data and the descriptive text data to obtain the target vector data and storing it in a preset vector database.

[0007] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of performing similarity retrieval in the knowledge graph and the target vector data based on the first text information input by the user to obtain at least one second text information includes: performing semantic understanding on the first text information to identify a first entity and query intent in the first text information; performing graph traversal retrieval in the knowledge graph based on the key entity and the query intent to obtain a second entity and relationship path associated with the first entity within a preset number of hops, and using the second entity and the relationship path as a first candidate set; vectorizing the first text information to obtain a query vector, performing an approximate nearest neighbor search in the target vector data to obtain several candidate text information, and using the candidate text information as a second candidate set; wherein, the candidate text information is an original text fragment or descriptive text, and the vector similarity between the vector corresponding to the candidate text information and the query vector is greater than a first similarity threshold; and obtaining at least one second text information based on the first candidate set and the second candidate set.

[0008] In conjunction with the first aspect, in one possible implementation of the first aspect, obtaining at least one second text information based on the first candidate set and the second candidate set includes: fusing and reordering the first candidate set and the second candidate set to generate the at least one second text information.

[0009] In conjunction with the first aspect, in one possible implementation of the first aspect, obtaining at least one second text information based on the first candidate set and the second candidate set includes: obtaining a first correlation value between each second entity in the first candidate set and its corresponding relationship path; obtaining a second correlation value for each candidate text information in the second candidate set; performing a weighted calculation on the first correlation value and the second correlation value according to a preset confidence algorithm to obtain a plurality of third correlation values; determining the third correlation value greater than a second similarity threshold as the target correlation value, and using the second entity corresponding to the target correlation value, the relationship path corresponding to the second entity, and the candidate text information as the second text information.

[0010] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of obtaining raw text data, extracting entities from the raw text data and identifying the relationships between the entities through a first large language model to obtain triplet data and descriptive text data corresponding to each entity includes: extracting entities from the raw text data and identifying the relationships between the entities based on a preset prompt word template, obtaining candidate triplet data; performing normalization, standardization, and filtering processing on the candidate triplet data to obtain the triplet data; and generating descriptive text data corresponding to each entity based on each entity in the triplet data.

[0011] In conjunction with the first aspect, in one possible implementation of the first aspect, the step of inputting the second text information into the second language model so that the second language model outputs text retrieval results based on the second text information includes: organizing the second text information through the second language model to obtain third text information; and templateting the third text information using a preset template to obtain the text retrieval results.

[0012] A second aspect of this application provides a knowledge graph-based retrieval device, comprising: an acquisition module for acquiring raw text data, extracting entities from the raw text data and identifying relationships between the entities using a first language model, to obtain triple data and descriptive text data corresponding to each entity; a construction module for constructing a knowledge graph and target vector data based on the raw text data, the triple data, and the descriptive text data; wherein the knowledge graph is composed of the triple data as nodes, and the target vector data is composed of the vectorized raw text data and the descriptive text data; a retrieval module for performing similarity retrieval in the knowledge graph and the target vector data based on first text information input by a user, to obtain at least one second text information; and a generation module for inputting the second text information into a second language model, so that the second language model outputs text retrieval results based on the second text information.

[0013] A third aspect of this application provides an electronic device, comprising: Processor; and A memory that stores executable code, which, when executed by the processor, causes the processor to perform the method described above.

[0014] A fourth aspect of this application provides a computer-readable storage medium having executable code stored thereon, which, when executed by a processor of an electronic device, causes the processor to perform the method described above.

[0015] The fifth aspect of this application provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the method described above.

[0016] The technical solution provided in this application may include the following beneficial effects: This application discloses a knowledge graph-based retrieval method and related apparatus, comprising: acquiring original text data; extracting entities from the original text data and identifying relationships between entities using a first large language model to obtain triple data and descriptive text data corresponding to each entity; constructing a knowledge graph and target vector data based on the original text data, triple data, and descriptive text data; wherein the knowledge graph is composed of triple data as nodes, and the target vector data is composed of vectorized original text data and descriptive text data; performing similarity retrieval in the knowledge graph and target vector data based on first text information input by the user to obtain at least one second text information; and inputting the second text information into a second large language model so that the second large language model outputs text retrieval results based on the second text information. In this method, by automatically extracting entity relationships to construct a knowledge graph and combining it with vector data for retrieval, the efficiency of knowledge graph construction and retrieval accuracy can be improved, the generation of model illusions can be reduced, and the accuracy of text retrieval results can be improved.

[0017] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description

[0018] The above and other objects, features and advantages of this application will become more apparent from the more detailed description of exemplary embodiments thereof in conjunction with the accompanying drawings, wherein the same reference numerals generally represent the same components in the exemplary embodiments thereof.

[0019] Figure 1 This is a schematic flowchart illustrating a knowledge graph-based retrieval method according to an embodiment of this application; Figure 2 This is a schematic diagram of the structure of a knowledge graph-based retrieval device shown in an embodiment of this application; Figure 3 This is a schematic diagram of the structure of an electronic device shown in an embodiment of this application. Detailed Implementation

[0020] Embodiments of this application will now be described in more detail with reference to the accompanying drawings. While embodiments of this application are shown in the drawings, it should be understood that this application may be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided to make this application more thorough and complete, and to fully convey the scope of this application to those skilled in the art.

[0021] The terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. The singular forms “a,” “the,” and “the” used in this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0022] It should be understood that although the terms "first," "second," "third," etc., may be used in this application to describe various information, this information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0023] As the digitization of text documents becomes more widespread within enterprises, the number of electronic documents continues to increase over time. In particular, these documents are often in non-standard, complex, and unstructured formats, making it impossible to directly apply traditional database query methods. This hinders internal personnel from quickly locating the required documents and from directly obtaining the key information needed within them.

[0024] Traditional methods rely on manually defining entity types and relational patterns. This approach has significantly insufficient generalization ability when faced with texts with highly diverse linguistic expressions. Furthermore, when using large language models for retrieval, the lack of factual knowledge in these models can lead to illusions, resulting in the generation of incorrect or untrue answers. Consequently, large language models are unable to provide the required key information based on the matched text, thus increasing the difficulty for users to filter and extract effective information.

[0025] To address the aforementioned issues, this application provides a knowledge graph-based retrieval method and related apparatus. By automatically extracting entity relationships to construct a knowledge graph and combining it with vector data for retrieval, this method can improve the efficiency of knowledge graph construction and retrieval accuracy, reduce model illusions, and enhance the accuracy of text retrieval results.

[0026] The technical solutions of the embodiments of this application are described in detail below with reference to the accompanying drawings.

[0027] Figure 1 This is a schematic flowchart illustrating a knowledge graph-based retrieval method according to an embodiment of this application.

[0028] See Figure 1 A knowledge graph-based retrieval method includes: S110: Obtain the original text data, extract entities from the original text data and identify the relationships between entities through the first language model, and obtain triple data and descriptive text data corresponding to each entity.

[0029] Specifically, raw text data refers to unstructured text data, such as patent abstracts, product technical documents, annual financial reports, news reports, meeting minutes, etc. The first large language model can be a preset large language model, such as Qwen3-80B-A3B-Instruct. After inputting the raw text data into the first large language model, the entities in the raw text data and the relationships between the entities can be obtained. Entities can be names of people, places, organizations, etc. The relationships between entities refer to the semantic connections between two or more entities, such as "inventor-invention-patent" and "company-production-product". Multiple triple data and descriptive text data corresponding to each entity are obtained. The triple data includes subject entity-relationship-object entity. The descriptive text data is a text fragment generated for each entity that details its meaning or attributes. For example, for the entity "Company A", the descriptive text "Company A is an enterprise focused on technology research and development" can be generated.

[0030] In one possible implementation, the process involves acquiring raw text data, extracting entities from the raw text data and identifying the relationships between entities using a first language model, and obtaining triplet data and descriptive text data corresponding to each entity. This includes: extracting entities from the raw text data and identifying the relationships between entities using a first language model based on a preset prompt word template, and obtaining candidate triplet data; performing normalization, standardization, and filtering processing on the candidate triplet data to obtain triplet data; and generating descriptive text data corresponding to each entity based on each entity in the triplet data.

[0031] Specifically, the pre-defined prompt template can instruct the first major language model to identify entities and their relationships in the original text data. For example, the prompt template can instruct the model to "extract all companies and their founders from the following text and list them in triplet form." The first major language model can be a Transformer-based pre-trained model that can identify entities from the original text data to output candidate triplet data. Then, the candidate triplet data can be normalized to eliminate inconsistencies in entity and relation representations. For example, different representations of the same entity, such as "Apple Inc.", "Apple Inc.", and "Apple," can be normalized to "Apple" to ensure consistency of entities and relations in the knowledge graph. Simultaneously, standardization and filtering are performed. Standardization ensures that the format and type of the candidate triplet data conform to the knowledge graph format and removes noise or irrelevant information from the candidate triplet data, resulting in processed triplet data. Finally, the first major language model can generate descriptive text data corresponding to each entity in the triplet data. The descriptive text data is used to supplement the explanation of the entity.

[0032] S120: Construct a knowledge graph and target vector data based on the original text data, triple data, and descriptive text data; wherein, the knowledge graph is composed of triple data as nodes, and the target vector data is composed of the vectorized original text data and descriptive text data.

[0033] Specifically, knowledge graphs are constructed using triplet data as nodes. Each entity can be considered a node in the graph, and the relationships between entities can be considered edges connecting these nodes. Target vector data is constructed by vectorizing the original text data and descriptive text data.

[0034] In one possible implementation, a knowledge graph and target vector data are constructed based on the original text data, triple data, and descriptive text data, including: storing entities in the triple data as nodes and the relationships between entities as connecting edges in a preset graph database to construct the knowledge graph; and vectorizing the original text data and descriptive text data to obtain target vector data, and storing it in a preset vector database.

[0035] Specifically, graph databases can be Neo4j, JanusGraph, etc. Graph databases store data in the form of nodes, edges, and attributes, which can efficiently represent and query complex relationships between entities. Deep learning models such as BERT can be used to vectorize the original text data and descriptive text data, converting this text information into high-dimensional numerical vectors and storing them in a vector database. Subsequently, searches can be performed in the vector database using Approximate Nearest Neighbor (ANN) search. Through graph databases and vector databases, when performing similarity retrieval in knowledge graphs and target vector data, appropriate query mechanisms can be selected for different types of data (structured relationships and unstructured semantics), thereby improving the efficiency and accuracy of retrieval.

[0036] S130: Based on the first text information input by the user, perform similarity retrieval in the knowledge graph and target vector data to obtain at least one second text information.

[0037] Specifically, the first text information is the query text input by the user. When the user inputs the first text information, keyword matching can be used to search for entities or relationships related to the query in the node names and relationship types of the knowledge graph. Alternatively, the first text information can be vectorized, and then cosine similarity calculations can be performed between the first text information and all vectors in the target vector data to find the original text fragment or entity description that is semantically closest to the query text. This allows the acquisition of knowledge fragments or text content related to the first text information, which serves as the second text information.

[0038] In one possible implementation, based on the first text information input by the user, a similarity retrieval is performed in a knowledge graph and target vector data to obtain at least one second text information, including: performing semantic understanding on the first text information to identify a first entity and query intent in the first text information; based on the key entity and query intent, performing graph traversal retrieval in the knowledge graph to obtain a second entity and relational path associated with the first entity within a preset number of hops, and using the second entity and relational path as a first candidate set; vectorizing the first text information to obtain a query vector, performing an approximate nearest neighbor search in the target vector data to obtain several candidate text information, and using the candidate text information as a second candidate set; wherein, the candidate text information is an original text fragment or descriptive text, and the vector similarity between the vector corresponding to the candidate text information and the query vector is greater than a first similarity threshold; and obtaining at least one second text information based on the first candidate set and the second candidate set.

[0039] Specifically, after obtaining the first text information, the first entity can be obtained from the first text information, and the user's query intent can be determined. For example, the first entity can be identified from the first text information through natural language processing (NLP) technology, and the query intent can be obtained through an intent recognition model. Then, a graph traversal retrieval is performed in the knowledge graph. Starting from the first entity, the neighboring entities and relationships are explored along the relation edges to discover structured knowledge related to the query intent. By setting a preset hop count range, such as 2 hops, the depth of traversal can be limited to avoid excessive diffusion of irrelevant information. Related second entities and relational paths are obtained to form the first candidate set. For example, the depth-first search (DFS) algorithm can be used to explore all reachable second entities and corresponding relational paths within the preset hop count, starting from the first entity.

[0040] Specifically, after vectorizing the first text information, a query vector can be obtained. Based on the query vector, a search is performed in the target vector data to obtain several candidate text information. The candidate text information is text information with similar vector similarity to the first text information. The first similarity threshold can be preset, and a second candidate set is constructed. Then, the first candidate set and the second candidate set are merged, and suitable second text information is selected from them. For example, the two candidate sets can be merged and deduplicated, and then sorted. The text information with the highest ranking is taken as the second text information.

[0041] In one possible implementation, obtaining at least one second text information based on a first candidate set and a second candidate set includes: fusing and reordering the first candidate set and the second candidate set to generate at least one second text information.

[0042] Specifically, merging the first and second candidate sets can remove duplicates or conflicting information that may exist in the two sets. For example, the second entities and their relationship paths contained in the first candidate set and the candidate text information contained in the second candidate set can be merged. During the merging process, items with similar content or pointing to the same concept can be deduplicated. Then, the merged set can be reordered according to the relevance to the user query, and the text information that ranks first can be used as the second text information. For example, the top five text information in the merged set can be used as the second text information.

[0043] For example, a first candidate set (e.g., containing entity A, entity B and their relationship paths) and a second candidate set (e.g., containing text fragment X and text fragment Y) can be merged into a new set. For example, the new set may contain "entity A-relationship-entity B", "text fragment X", and "text fragment Y". During the merging process, duplicate or highly similar items can be deduplicated. For example, if the description text of entity A is highly consistent with the content of text fragment X, they can be regarded as the same item. Then, the merged set is reordered.

[0044] In one possible implementation, obtaining at least one second text information based on a first candidate set and a second candidate set includes: obtaining a first correlation value between each second entity in the first candidate set and its corresponding relationship path; obtaining a second correlation value for each candidate text information in the second candidate set; performing a weighted calculation on the first correlation value and the second correlation value according to a preset confidence algorithm to obtain several third correlation values; determining the third correlation value that is greater than a second similarity threshold as the target correlation value, and using the second entity corresponding to the target correlation value, the relationship path corresponding to the second entity, and the candidate text information as the second text information.

[0045] Specifically, when generating the first candidate set, a first correlation value can be generated between each second entity and its corresponding relational path. This first correlation value can be determined by the number of hops in the graph traversal; for example, fewer hops result in a higher correlation value. Each candidate text in the second candidate set corresponds to a second correlation value, which can be obtained by calculating the cosine similarity of each candidate text. The preset confidence algorithm can be: S 总 =W1 First correlation value + W2 The second correlation value, S 总 The third relevance value is used, and the second similarity threshold can be preset.

[0046] For example, if the user inputs the first text message "What is the processor model of Apple's latest iPhone?", the system first performs semantic understanding to identify "Apple's latest iPhone" as the first entity, with the query intent being "processor model". Then, a graph traversal search is performed on the knowledge graph to obtain a first candidate set, which includes "iPhone 15 Pro Max" as the second entity, and "Apple" -- (manufacturing) --> "iPhone 15 Pro Max" -- (equipped with) --> "A17 Bionic" as the relationship path. The first relevance value of this path can be calculated; for example, based on the path length and the importance of the relationship type, the first relevance value is calculated to be 0.85. Simultaneously, the user input is vectorized to obtain a query vector. An approximate nearest neighbor search is performed on the target vector data to obtain a second candidate set, which includes the text fragment "iPhone 15 Pro Max is equipped with the latest A17 Bionic chip, with excellent performance". The vector similarity between this text fragment and the query vector is calculated as a second relevance value; for example, the second relevance value is calculated to be 0.90. Next, according to the preset confidence algorithm, where the weight of the first relevance value is set to 0.6 and the weight of the second relevance value is set to 0.4, the third relevance value is 0.87. If the preset second similarity threshold is 0.80, then the third relevance value can be determined as the target relevance value. Finally, "iPhone 15 Pro Max" (second entity), "Apple Inc." -- (manufacturing) --> "iPhone 15 Pro Max" -- (equipped with) --> "A17 Bionic" (relationship path), and "iPhone 15 Pro Max is equipped with the latest A17 Bionic chip, with excellent performance." (candidate text information) are output as the second text information.

[0047] S140: Input the second text information into the second language model so that the second language model can output text retrieval results based on the second text information.

[0048] Specifically, the second text information consists of knowledge fragments or text content related to the first text information. This information can be obtained from the original text data and descriptive text data. After inputting the second text information into the second large language model (e.g., Qwen3-80B), the second large language model can concatenate relevant paragraphs from the second text information to form an answer, which is then output as the text retrieval result. Furthermore, the second large language model can adopt the RAG (Retrieval-Augmented Generation) paradigm, enabling it to generate text retrieval results solely based on the provided second text information. This solution, by combining knowledge graphs and target vector data for hybrid retrieval, significantly improves the accuracy and reliability of the retrieval, effectively reducing the "illusion" problem that can occur with large models.

[0049] For example, the raw text data includes a company's internal product manuals, troubleshooting guides, R&D reports, etc. This raw text data is input into a first-level language model. The first-level language model analyzes the document content sentence by sentence, automatically identifying various entities mentioned in the document, such as "product model X," "fault code Y," "solution Z," "component A," and "functional module B." Simultaneously, it identifies the relationships between these entities, such as "product model X contains component A," "the solution to fault code Y is Z," and "functional module B depends on component A," generating a large amount of triple data, such as (product model X, contains, component A), and descriptive text for each entity, such as "product model X: our company's latest generation of intelligent devices, with high-performance processing capabilities." Each identified entity is then treated as a node in a knowledge graph, and the relationships between entities are represented as edges connecting these nodes. For example, in a knowledge graph, the "Product Model X" node and the "Component A" node are connected through an "inclusion" relationship. Simultaneously, each paragraph of the original technical document and the descriptive text of each entity are converted into high-dimensional vectors. These vectors collectively constitute the target vector data. When a user inputs the first text information, such as "How to solve fault code Y for product model X?", the system performs a similarity search. First, it conducts a preliminary analysis of the user's query, identifying keywords such as "product model X" and "fault code Y," and searches the knowledge graph for nodes and relationships related to "product model X" and "fault code Y." For example, it might find a "solution method" relationship between "fault code Y" and "solution Z." Simultaneously, it vectorizes user A's query text and searches the target vector data for document paragraphs or entity descriptions most similar to the query vector. For example, it might recall a text describing the specific manifestations of "fault code Y" and a text describing the operational steps of "solution Z." Finally, by combining the structured information in the knowledge graph and the semantic similarity in the target vector data, a series of knowledge fragments and text content highly relevant to the user's query are obtained and integrated into the second text information. Finally, after inputting the second text information into the second language model, the second language model will understand, organize, and generate information based on the user's original query, "How to resolve fault code Y for product model X?". For example, the second language model can integrate the "solution methods" relationships for "fault code Y" in the knowledge graph with the operational steps of "solution Z" retrieved by vector retrieval to generate a clear and coherent natural language answer, such as "For fault code Y for product model X, we suggest you perform the following steps: First check..., then try..., please refer to the documentation for specific operations..." This answer is the final text retrieval result and is displayed to the user.

[0050] In one possible implementation, the second text information is input into a second language model so that the second language model outputs text retrieval results based on the second text information, including: organizing the second text information through the second language model to obtain third text information; and templateting the third text information using a preset template to obtain text retrieval results.

[0051] Specifically, the second text information retrieved by the second language model may contain redundant information, irrelevant fragments, etc. Then, by using a preset template, the core points can be extracted from the second text information and duplicate information can be removed to obtain text retrieval results, which can improve the accuracy and consistency of the retrieval.

[0052] This application discloses a knowledge graph-based retrieval method, comprising: acquiring original text data; extracting entities from the original text data and identifying the relationships between entities using a first large language model to obtain triple data and descriptive text data corresponding to each entity; constructing a knowledge graph and target vector data based on the original text data, triple data, and descriptive text data; wherein the knowledge graph is composed of triple data as nodes, and the target vector data is composed of vectorized original text data and descriptive text data; performing similarity retrieval in the knowledge graph and target vector data based on first text information input by the user to obtain at least one second text information; and inputting the second text information into a second large language model so that the second large language model outputs text retrieval results based on the second text information. This method, by automatically extracting entity relationships to construct a knowledge graph and combining it with vector data for retrieval, can improve the efficiency of knowledge graph construction and retrieval accuracy, reduce model illusions, and improve the accuracy of text retrieval results.

[0053] Corresponding to the aforementioned application function implementation method embodiments, this application also provides a knowledge graph-based retrieval device, electronic device, and corresponding embodiments.

[0054] Figure 2 This is a schematic diagram of the structure of a knowledge graph-based retrieval device shown in an embodiment of this application.

[0055] See Figure 2 A knowledge graph-based retrieval device 200 includes: The acquisition module 210 is used to acquire raw text data, extract entities from the raw text data and identify the relationships between entities through the first language model, and obtain triple data and descriptive text data corresponding to each entity.

[0056] In one possible implementation, the acquisition module 210 is further configured to extract entities from the original text data and identify the relationships between entities based on a preset prompt word template using a first language model to obtain candidate triplet data; perform normalization, standardization, and filtering on the candidate triplet data to obtain triplet data; and generate descriptive text data corresponding to each entity based on each entity in the triplet data.

[0057] The construction module 220 is used to construct a knowledge graph and target vector data based on the original text data, triple data, and descriptive text data; wherein, the knowledge graph is composed of triple data as nodes, and the target vector data is composed of the vectorized original text data and descriptive text data.

[0058] In one possible implementation, the construction module 220 is further configured to store entities in the triplet data as nodes and the relationships between entities as connecting edges in a preset graph database to construct a knowledge graph; and to vectorize the original text data and descriptive text data to obtain target vector data, and store it in a preset vector database.

[0059] The retrieval module 230 is used to perform similarity retrieval in the knowledge graph and target vector data based on the first text information input by the user, and obtain at least one second text information.

[0060] In one possible implementation, the retrieval module 230 is further configured to perform semantic understanding on the first text information, identify the first entity and query intent in the first text information; based on the key entity and query intent, perform graph traversal retrieval in the knowledge graph to obtain the second entity and relational path associated with the first entity within a preset number of hops, and use the second entity and relational path as the first candidate set; after vectorizing the first text information to obtain the query vector, perform an approximate nearest neighbor search in the target vector data to obtain several candidate text information, and use the candidate text information as the second candidate set; wherein, the candidate text information is the original text fragment or descriptive text, and the vector similarity between the vector corresponding to the candidate text information and the query vector is greater than a first similarity threshold; and based on the first candidate set and the second candidate set, obtain at least one second text information.

[0061] In one possible implementation, the retrieval module 230 is further configured to merge and reorder the first candidate set and the second candidate set to generate at least one second text information.

[0062] In one possible implementation, the retrieval module 230 is further configured to obtain a first correlation value between each second entity and its corresponding relation path in the first candidate set; obtain a second correlation value for each candidate text information in the second candidate set; perform weighted calculation on the first correlation value and the second correlation value according to a preset confidence algorithm to obtain several third correlation values; determine the third correlation value that is greater than the second similarity threshold as the target correlation value, and use the second entity corresponding to the target correlation value, the relation path corresponding to the second entity, and the candidate text information as the second text information.

[0063] The generation module 240 is used to input the second text information into the second language model so that the second language model can output text retrieval results based on the second text information.

[0064] In one possible implementation, the generation module 240 is further configured to organize the second text information using a second language model to obtain third text information; and to template the third text information using a preset template to obtain text retrieval results.

[0065] This application discloses a knowledge graph-based retrieval device, comprising: an acquisition module for acquiring raw text data, extracting entities from the raw text data and identifying relationships between entities using a first language model to obtain triple data and descriptive text data corresponding to each entity; a construction module for constructing a knowledge graph and target vector data based on the raw text data, triple data, and descriptive text data; wherein the knowledge graph is composed of triple data as nodes, and the target vector data is composed of vectorized raw text data and descriptive text data; a retrieval module for performing similarity retrieval in the knowledge graph and target vector data based on first text information input by the user to obtain at least one second text information; and a generation module for inputting the second text information into a second language model so that the second language model outputs text retrieval results based on the second text information. In this method, by automatically extracting entity relationships to construct a knowledge graph and combining it with vector data for retrieval, the efficiency of knowledge graph construction and retrieval accuracy can be improved, model illusions can be reduced, and the accuracy of text retrieval results can be improved.

[0066] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated further here.

[0067] This application also provides an electronic device. Figure 3This is a schematic diagram of the hardware structure of an embodiment of the electronic device of this application. The electronic device includes a memory 320 and at least one processor 310. The memory 320 is electrically connected to the at least one processor 310. The memory 320 stores instructions. The at least one processor 310 calls the instructions in the memory 320, causing the electronic device to execute the knowledge graph-based retrieval method according to any of the foregoing embodiments of this application.

[0068] Specifically, the processor 310 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0069] Memory 320 may include a mass storage device for data or instructions. For example, and not limitingly, memory 320 may include a hard disk drive (HDD), floppy disk drive, flash memory, optical disk, magneto-optical disk, magnetic tape, or Universal Serial Bus (USB) drive, or a combination of two or more of these. Where appropriate, memory 320 may include removable or non-removable (or fixed) media. Where appropriate, memory 320 may be internal or external to the integrated gateway disaster recovery device. In a particular embodiment, memory 320 is non-volatile solid-state memory. In a particular embodiment, memory 320 includes read-only memory (ROM). Where appropriate, the ROM may be a mask-programmed ROM, a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable PROM (EEPROM), an electrically rewritable ROM (EAROM), or flash memory, or a combination of two or more of these.

[0070] In one example, the control device may also include a communication interface 330 and a bus 340. The processor 310, memory 320, and communication interface 330 are connected via the bus 340 and communicate with each other.

[0071] The communication interface 330 is mainly used to realize communication between various modules, devices, units and / or equipment in the embodiments of this application.

[0072] Bus 340 includes hardware, software, or both, that couples components of an online data traffic metering device together. For example, and not limitingly, the bus may include an Accelerated Graphics Port (AGP) or other graphics bus, an Enhanced Industry Standard Architecture (EISA) bus, a Front Side Bus (FSB), HyperTransport (HT) interconnect, an Industry Standard Architecture (ISA) bus, an Infinite Bandwidth Interconnect, a Low Pin Count (LPC) bus, a Microchannel Architecture (MCA) bus, a Peripheral Component Interconnect (PCI) bus, a PCI-Express (PCI-X) bus, a Serial Advanced Technology Attachment (SATA) bus, a Video Electronics Standards Association Local (VLB) bus, or other suitable buses, or combinations of two or more of these. Where appropriate, bus 340 may include one or more buses. Although specific buses are described and illustrated in embodiments of this application, any suitable bus or interconnect is contemplated herein.

[0073] Furthermore, in conjunction with the knowledge graph-based retrieval methods in the above embodiments, this application embodiment can provide a computer-readable storage medium for implementation. This computer-readable storage medium stores executable code, which, when executed by a processor, implements any of the knowledge graph-based retrieval methods in the above embodiments.

[0074] This application is not limited to the specific configurations and processes described above and shown in the figures. For the sake of brevity, detailed descriptions of known methods are omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of this application is not limited to the specific steps described and shown. Those skilled in the art can make various changes, modifications, and additions, or change the order of steps, after understanding the spirit of this application.

[0075] The functional blocks shown in the above block diagram can be implemented as hardware, software, firmware, or a combination thereof. When implemented in hardware, they can be, for example, electronic circuits, application-specific integrated circuits (ASICs), appropriate firmware, plug-ins, function cards, etc. When implemented in software, the elements of this application are programs or code segments used to perform the required tasks. Programs or code segments can be stored on a machine-readable medium or transmitted over a transmission medium or communication link via data signals carried on a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, fiber optic media, radio frequency (RF) links, etc. Code segments can be downloaded via computer networks such as the Internet, intranets, etc.

[0076] It should also be noted that the exemplary embodiments mentioned in this application describe methods or systems based on a series of steps or apparatus. However, this application is not limited to the order of the above steps; that is, the steps can be performed in the order mentioned in the embodiments, or in a different order, or several steps can be performed simultaneously.

[0077] The above are merely specific embodiments of this application. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, modules, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. It should be understood that the protection scope of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the protection scope of this application.

Claims

1. A knowledge graph based retrieval method, characterized in that, include: The original text data is obtained, and entities in the original text data are extracted and the relationships between the entities are identified through the first language model to obtain triple data and descriptive text data corresponding to each entity. Based on the original text data, the triple data, and the descriptive text data, a knowledge graph and target vector data are constructed; wherein, the knowledge graph is composed of the triple data as nodes, and the target vector data is composed of the vectorized original text data and the descriptive text data; Based on the first text information input by the user, a similarity search is performed between the knowledge graph and the target vector data to obtain at least one second text information. The second text information is input into the second language model so that the second language model outputs text retrieval results based on the second text information.

2. The method according to claim 1, characterized in that, The construction of a knowledge graph and target vector data based on the original text data, the triplet data, and the descriptive text data includes: The entities in the triplet data are stored as nodes, and the relationships between the entities are stored as connecting edges in a preset graph database to construct the knowledge graph; The original text data and the descriptive text data are vectorized to obtain the target vector data, which is then stored in a preset vector database.

3. The method according to claim 1, characterized in that, The step of performing a similarity search on the knowledge graph and the target vector data based on the first text information input by the user to obtain at least one second text information includes: Perform semantic understanding on the first text information to identify the first entity and query intent in the first text information; Based on the key entity and the query intent, a graph traversal retrieval is performed in the knowledge graph to obtain a second entity and a relationship path that are associated with the first entity within a preset number of hops, and the second entity and the relationship path are used as a first candidate set. The first text information is vectorized to obtain a query vector. An approximate nearest neighbor search is performed on the target vector data to obtain several candidate text information, and the candidate text information is used as a second candidate set. The candidate text information is either an original text fragment or descriptive text, and the vector similarity between the vector corresponding to the candidate text information and the query vector is greater than a first similarity threshold. Based on the first candidate set and the second candidate set, at least one second text information is obtained.

4. The method according to claim 3, characterized in that, The step of obtaining at least one second text information based on the first candidate set and the second candidate set includes: The first candidate set and the second candidate set are merged and reordered to generate at least one second text information.

5. The method according to claim 3, characterized in that, The step of obtaining at least one second text information based on the first candidate set and the second candidate set includes: Obtain the first correlation value between each second entity in the first candidate set and its corresponding relationship path; Obtain the second relevance value for each candidate text information in the second candidate set; According to a preset confidence algorithm, the first correlation value and the second correlation value are weighted and calculated to obtain several third correlation values; A third relevance value greater than the second similarity threshold is determined as the target relevance value, and the second entity corresponding to the target relevance value, the relationship path corresponding to the second entity, and the candidate text information are taken as the second text information.

6. The method according to claim 1, characterized in that, The process of acquiring raw text data involves extracting entities from the raw text data using a first language model and identifying the relationships between the entities to obtain triplet data and descriptive text data corresponding to each entity, including: Based on the preset prompt word template, entities in the original text data are extracted and the relationships between the entities are identified through the first major language model to obtain candidate triplet data; The candidate triplet data is normalized, standardized, and filtered to obtain the triplet data. Based on each entity in the triplet data, generate descriptive text data corresponding to each entity.

7. The method according to claim 1, characterized in that, The step of inputting the second text information into the second language model, so that the second language model outputs text retrieval results based on the second text information, includes: The second language model is used to organize the second text information to obtain the third text information; The third text information is templated using a preset template to obtain the text search results.

8. A knowledge graph-based retrieval device, characterized in that, include: The acquisition module is used to acquire raw text data, extract entities from the raw text data and identify the relationships between the entities through the first language model, and obtain triple data and descriptive text data corresponding to each entity. A construction module is used to construct a knowledge graph and target vector data based on the original text data, the triple data, and the descriptive text data; wherein, the knowledge graph is composed of the triple data as nodes, and the target vector data is composed of the vectorized original text data and the descriptive text data; The retrieval module is used to perform similarity retrieval in the knowledge graph and the target vector data based on the first text information input by the user, and obtain at least one second text information. The generation module is used to input the second text information into the second language model so that the second language model can output text retrieval results based on the second text information.

9. An electronic device, characterized in that, include: processor; as well as A memory having executable code stored thereon, which, when executed by the processor, causes the processor to perform the method as described in any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, It stores executable code that, when executed by a processor of an electronic device, causes the processor to perform the method as described in any one of claims 1-7.