Knowledge retrieval method and device

The knowledge group set is determined through entity extraction and semantic similarity, and knowledge retrieval is combined with large language models, which solves the problem of low knowledge retrieval accuracy in the existing technology, and achieves the generation of more accurate and comprehensive answers.

CN119202137AInactive Publication Date: 2024-12-27IFLYTEK (SUZHOU) TECH CO LTD

Patent Information

Application Number
CN202411489781.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-24
Publication Date
2024-12-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The search accuracy of existing knowledge retrieval schemes is low and cannot meet users' requirements for high accuracy. Especially in human-computer interaction tasks, it is difficult to effectively obtain knowledge matching user problems.

Method used

By performing entity extraction of the question text, determining the first and second knowledge sets from the knowledge graph based on semantic similarity, and combining large language models for knowledge search, the search prompt text is constructed to generate more comprehensive and accurate answers.

Benefits of technology

Improves the accuracy of knowledge retrieval, ensures correlation with specific terms and concepts in the question text, and matches overall semantics, generating more comprehensive and accurate answer text.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202137A_ABST
    Figure CN119202137A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of natural language processing, and provides a knowledge retrieval method and device.The method comprises the steps that entity extraction is conducted on a question text, and question entities are obtained; based on the semantic similarity between the question entity and each knowledge node in the knowledge graph, determining a first knowledge group set aligned with the question entity from the knowledge graph; based on the semantic similarity between the question text and each knowledge group in a knowledge graph, determining a second knowledge group set from the knowledge graph, the knowledge graph comprising a plurality of knowledge groups, and the relevancy between knowledge nodes in the same knowledge group being greater than a threshold; and based on the first knowledge group set, the second knowledge group set and the question text, performing knowledge retrieval. According to the method, knowledge retrieval can be carried out on the basis of being related to specific terms and concepts in the question text and being related to the content of the question text in overall semantics, and a more comprehensive and accurate answer text is generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of natural language processing technology, and in particular to a knowledge retrieval method and device. Background Art

[0002] In human-computer interaction tasks, if the questions input by the user involve external knowledge, the machine needs to use the knowledge retrieval system to search the knowledge base and obtain the knowledge that matches the questions input by the user to complete the conversation.

[0003] The existing knowledge retrieval schemes have low retrieval accuracy, while users have increasingly higher requirements for retrieval accuracy. Therefore, there is an urgent need for a knowledge retrieval method with higher retrieval accuracy to meet users' requirements for retrieval accuracy. Summary of the invention

[0004] The present invention provides a knowledge retrieval method and device to solve the defects in the prior art.

[0005] The present invention provides a knowledge retrieval method, comprising the following steps: Perform entity extraction on the question text to obtain question entities; Based on the semantic similarity between the question entity and each knowledge node in the knowledge graph, determining a first knowledge group set aligned with the question entity from the knowledge graph; Based on the semantic similarity between the question text and each knowledge group in the knowledge graph, determining a second knowledge group set from the knowledge graph, wherein the knowledge graph includes a plurality of the knowledge groups, and the correlation between each knowledge node in the same knowledge group is greater than a threshold; Knowledge retrieval is performed based on the first knowledge group set, the second knowledge group set and the question text.

[0006] According to a knowledge retrieval method provided by the present invention, the knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text includes: Constructing a search prompt text based on the first knowledge group set, the second knowledge group set and the question text; The search prompt text is input into a large language model, and the large language model performs knowledge search to obtain an answer text corresponding to the question text.

[0007] According to a knowledge retrieval method provided by the present invention, constructing a retrieval prompt text based on the first knowledge group set, the second knowledge group set and the question text includes: Extracting semantic features of the question text and semantic features of each of the knowledge groups in a knowledge group set, wherein the knowledge group set includes the first knowledge group set and the second knowledge group set; Determining a reference knowledge group from the knowledge group set based on the semantic relevance between the semantic features of the question text and the semantic features of each of the knowledge groups; The search prompt text is constructed based on the reference knowledge group and the question text.

[0008] According to a knowledge retrieval method provided by the present invention, the entity extraction of the question text also includes: Performing grammatical analysis on the question text to determine missing elements of the question text; Determining filling content corresponding to the missing element based on the historical dialogue text of the question text; Based on the fill-in content, the question text is rewritten.

[0009] According to a knowledge retrieval method provided by the present invention, the knowledge graph is constructed based on the following steps: Split the knowledge document to obtain multiple initial knowledge blocks; Based on the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks, each of the initial knowledge blocks is split or reorganized to obtain a plurality of the knowledge groups in the knowledge graph; Triples are extracted from each of the knowledge groups, and knowledge nodes under each of the knowledge groups are determined based on the extraction results.

[0010] According to a knowledge retrieval method provided by the present invention, based on the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks, each of the initial knowledge blocks is split or reorganized to obtain a plurality of the knowledge groups in the knowledge graph, including: Based on each of the initial knowledge blocks, the knowledge document and the output knowledge group requirements, construct a segmentation prompt text; The segmentation prompt text is input into a large language model, and the large language model extracts the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks based on the segmentation prompt text, and splits or reorganizes each of the initial knowledge blocks based on the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks to obtain the multiple knowledge groups in the knowledge graph.

[0011] According to a knowledge retrieval method provided by the present invention, the triple extraction of each of the knowledge groups further includes: Based on the semantic information of each of the knowledge groups, knowledge detection is performed on each of the knowledge groups.

[0012] The present invention also provides a knowledge retrieval device, comprising the following modules: An entity extraction unit is used to extract entities from question text to obtain question entities; A first determining unit, configured to determine, from the knowledge graph, a first set of knowledge groups aligned with the question entity based on the semantic similarity between the question entity and each knowledge node in the knowledge graph; A second determination unit is used to determine a second set of knowledge groups from the knowledge graph based on the semantic similarity between the question text and each knowledge group in the knowledge graph, wherein the knowledge graph includes a plurality of the knowledge groups, and the correlation between each of the knowledge nodes in the same knowledge group is greater than a threshold; The knowledge retrieval unit is used to perform knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text.

[0013] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the above-mentioned knowledge retrieval methods is implemented.

[0014] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the knowledge retrieval method described in any one of the above is implemented.

[0015] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned knowledge retrieval methods.

[0016] The knowledge retrieval method and device provided by the present invention recall the first knowledge group set from the domain word level and recall the second knowledge group set from the semantic level. Therefore, when the first knowledge group set and the second knowledge group set are combined for knowledge retrieval, it can be ensured that the knowledge retrieval is performed on the basis of being relevant to the specific terms and concepts in the question text and being relevant to the content of the question text in terms of overall semantics, thereby generating a more comprehensive and accurate answer text. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0018] Figure 1 This is one of the flow charts of the knowledge retrieval method provided by the present invention.

[0019] Figure 2 It is a flowchart of the implementation of step 140 in the knowledge retrieval method provided by the present invention.

[0020] Figure 3 It is a flowchart of the implementation of step 141 in the knowledge retrieval method provided by the present invention.

[0021] Figure 4 It is a flowchart of the knowledge graph construction method provided by the present invention.

[0022] Figure 5 It is a schematic diagram of the process of offline construction of a knowledge graph provided by the present invention.

[0023] Figure 6 This is the second flowchart of the knowledge retrieval method provided by the present invention.

[0024] Figure 7 It is a structural schematic diagram of the knowledge retrieval device provided by the present invention.

[0025] Figure 8 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0026] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] Retrieval-augmented Generation (RAG) is a natural language processing technology that combines a retriever with a generator for retrieval. Specifically, the retriever is first used to find relevant information from a large-scale document library, and then this information is provided to the generator to generate more accurate and detailed answers.

[0028] RAG is generally implemented using dense retrieval, which performs retrieval by calculating the similarity between question text and knowledge documents. However, relying entirely on similarity sometimes causes the retriever to be unable to help the generator obtain cross-paragraph or document knowledge related to the user's question, thereby reducing the accuracy of the generated answer.

[0029] In addition, in actual business dialogue system application scenarios, in the same conversation, users often use questions with missing semantics or missing subjects and objects, resulting in the RAG retriever being able to only retrieve knowledge with semantic deviations or missing premises in multi-round conversations, thereby reducing the accuracy of generated answers.

[0030] When preprocessing knowledge, RAG-based question-answering systems usually divide knowledge into paragraphs or length granularities without considering semantic continuity and independence, which affects the quality of retrieval and thus reduces the accuracy of generated answers.

[0031] Figure 1 is one of the flow charts of the knowledge retrieval method provided by the present invention, such as Figure 1 As shown, the method includes step 110 , step 120 , step 130 and step 140 .

[0032] Step 110: extract entity from the question text to obtain question entities.

[0033] Here, the question text can be understood as the text used by the user to seek answers or obtain information, and the question text can be a question text in any field. The question entity is a key noun or proper noun extracted from the question text. Among them, the question text can be directly input by the user, or it can be obtained by voice transcription of the collected audio, or it can be obtained by collecting images through image acquisition devices such as scanners, mobile phones, cameras, and performing text recognition on the images. The embodiments of the present invention do not specifically limit this.

[0034] Optionally, before performing entity extraction on the question text input by the user, the question text may be firstly segmented (such as decomposing the question text into multiple segments and removing stop words), and then named entity recognition may be performed on the segmented question text to extract the question entity.

[0035] Step 120: Based on the semantic similarity between the question entity and each knowledge node in the knowledge graph, determine a first set of knowledge groups aligned with the question entity from the knowledge graph.

[0036] Specifically, in the question-answering system, the knowledge graph can be understood as a structured graph containing a large number of entities and the relationships between them. Entities usually include people, places, organizations, events, etc., while relationships describe the various associations between these entities. These entities can be understood as knowledge nodes in the knowledge graph.

[0037] In addition, a knowledge group can be understood as a collection of knowledge nodes with similar attributes or functions. For example, all company nodes can be classified into a "company" knowledge group, and all celebrities can be classified into a "celebrity" knowledge group.

[0038] The first knowledge group set includes multiple knowledge groups, and the knowledge nodes in each knowledge group are aligned with the question entity. It is understandable that the question text may include multiple question entities with different semantics, each question entity corresponds to a different knowledge group, and these knowledge groups constitute the first knowledge group set.

[0039] Among them, in an embodiment of the present invention, based on the semantic similarity between any question entity and each knowledge node in the knowledge graph, a target knowledge node aligned with any question entity can be determined, and based on the target knowledge node, the remaining knowledge nodes similar to the target knowledge node are searched in the knowledge graph. The set composed of the target knowledge node and the remaining similar knowledge nodes is the knowledge group corresponding to any question entity, and the knowledge groups corresponding to several question entities constitute a first knowledge group set.

[0040] Optionally, the question entity and the knowledge node can be semantically encoded respectively to obtain the semantic features of the question entity and the semantic features of the knowledge node, and the similarity between the question entity and each knowledge node can be determined based on the feature distance between the semantic features of the two. The smaller the feature distance, the higher the similarity between the two. Among them, the BERT semantic vector model can be used to semantically encode the question entity and the knowledge node respectively to obtain the semantic features of the question entity and the semantic features of the knowledge node. The feature distance between the semantic features of the two can be measured by cosine similarity, Euclidean distance, etc.

[0041] For example, a structured extractor can be used to extract question entities from question text q , using a semantic encoder For the problem entity Semantically encode the knowledge nodes in the knowledge graph and determine the entities related to the problem Aligned target knowledge nodes As a retrieval node. When determining the target knowledge node Finally, the PPR (PageRank) algorithm can be used in the knowledge graph to determine the target knowledge node The PPR algorithm is as follows: Assume that the knowledge graph includes N knowledge nodes and E edges, and use the personalized probability distribution π defined on the N knowledge nodes. Each knowledge node has equal probability, and the probability of other knowledge nodes is zero, so that the probability mass can be mainly distributed in After running the PPR algorithm, the updated probability distribution π' of each knowledge node in the knowledge graph is obtained. Finally, in order to obtain the paragraph score, π' is multiplied by the matrix P = |N| × |p| to obtain the ranking score score of each paragraph p, and the output ranking score score is used to recall the first knowledge group set Among them, the first knowledge group set It can be several knowledge nodes or paragraphs with high ranking scores, and paragraph p is a text paragraph associated with a knowledge node in the knowledge graph.

[0042] Among them, you can use ( ) measures the semantic similarity between the problem entity and each knowledge node, , S represents the similarity measurement method, which can be Euclidean distance, cosine similarity, etc.

[0043] Step 130: Based on the semantic similarity between the question text and each knowledge group in the knowledge graph, determine a second knowledge group set from the knowledge graph, the knowledge graph includes multiple knowledge groups, and the correlation between each knowledge node in the same knowledge group is greater than a threshold.

[0044] Specifically, the correlation between knowledge nodes is used to characterize the semantic similarity, attribute matching, relationship closeness, etc. between knowledge nodes. The semantic similarity, attribute matching or relationship closeness between knowledge nodes in the same knowledge group are higher.

[0045] The second knowledge group set includes multiple knowledge groups, each of which has a high semantic similarity with the question text. It is understandable that the question text may express multiple semantics, each semantic corresponds to a different knowledge group, and these knowledge groups constitute the second knowledge group set.

[0046] In this embodiment of the present invention, based on the semantic similarity between the question text and each knowledge node in the knowledge graph, a second knowledge group set with a higher semantic similarity to the question text can be determined. Determine the similarity probability of each knowledge group g , and according to the similarity probability Back to the second knowledge group , similarity probability Determined based on the following formula:

[0047] where τ is a temperature hyperparameter that controls the smoothness of the probability distribution. A higher τ will produce a smoother probability distribution. The semantic feature distance between each knowledge group g and the question text q can be used to measure the distance, and the semantic feature distance can be measured by cosine similarity or Euclidean distance.

[0048] Step 140: perform knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text.

[0049] Specifically, the first knowledge group set is recalled based on the semantic similarity between the question entity and each knowledge node in the knowledge graph, that is, when recalling the first knowledge group set, attention is paid to the degree of matching between the entity in the question text and each knowledge node in the knowledge graph. The matching is based on the similarity at the lexical level, that is, the first knowledge group set is recalled from the domain term level.

[0050] The second knowledge group set is recalled based on the semantic similarity between the question text and the knowledge groups in the knowledge graph. That is, when recalling the second knowledge group set, attention is paid to the overall semantics of the question text and the semantic consistency of the knowledge groups in the knowledge graph, that is, the second knowledge group set is recalled from a semantic level.

[0051] The first knowledge group set is recalled from the domain word level, providing a direct match to the question entity, ensuring that the knowledge retrieval is relevant to the specific terms and concepts in the question text. The second knowledge group set is recalled from the semantic level, ensuring that the knowledge retrieval is semantically relevant to the question text content. Combining the first knowledge group set and the second knowledge group set, it is possible to achieve comprehensive and accurate knowledge retrieval for the question text by making comprehensive use of entity names and context information, and obtain the answer text corresponding to the question text.

[0052] The knowledge retrieval method provided by the embodiment of the present invention recalls the first knowledge group set from the domain word level and the second knowledge group set from the semantic level. Therefore, when the first knowledge group set and the second knowledge group set are combined for knowledge retrieval, it can ensure that the knowledge retrieval is performed on the basis of being relevant to the specific terms and concepts in the question text and being relevant to the content of the question text in terms of overall semantics, thereby generating a more comprehensive and accurate answer text.

[0053] Based on the above embodiments, Figure 2 is a flow chart of an implementation of step 140 in the knowledge retrieval method provided by the present invention, such as Figure 2 As shown, step 140 performs knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text, including: Step 141: construct a search prompt text based on the first knowledge group set, the second knowledge group set and the question text; Step 142: input the search prompt text into the large language model, and use the large language model to perform knowledge search to obtain the answer text corresponding to the question text.

[0054] Specifically, the retrieval prompt text is used to guide the large language model to generate effective answer text for the question text. Since the first knowledge group set is recalled from the domain word level, it provides a direct match to the question entity, ensuring that the knowledge retrieval is relevant to the specific terms and concepts in the question text. The second knowledge group set is recalled from the semantic level, ensuring that the knowledge retrieval is semantically relevant to the content of the question text in terms of overall semantics. The retrieval prompt text constructed by combining the first knowledge group set, the second knowledge group set and the question text can realize the comprehensive use of entity names and contextual information, realize comprehensive and accurate knowledge retrieval for the question text, and obtain the answer text corresponding to the question text. Among them, the retrieval prompt text can be a Prompt text.

[0055] The above-mentioned large language model (LLM) is referred to as a large model, which refers to a natural language processing (NLP) model with a large parameter scale. The number of model parameters and / or the complexity of the model structure exceeds the preset threshold. The model processes large-scale text data during training and has the ability to understand and generate natural language. For example, large language models can include the Spark large model, etc.

[0056] Based on any of the above embodiments, Figure 3 is a flow chart of an implementation of step 141 in the knowledge retrieval method provided by the present invention, such as Figure 3 As shown, step 141 constructs a search prompt text based on the first knowledge group set, the second knowledge group set and the question text, including: Step 1411: extract semantic features of the question text and semantic features of each knowledge group in the knowledge group set, where the knowledge group set includes a first knowledge group set and a second knowledge group set.

[0057] Specifically, the semantic features of the question text are used to represent the semantic information of the question text, and the semantic features of each knowledge group in the knowledge group set are used to represent the semantic information of each knowledge group. The semantic features of both can be extracted using the BERT model.

[0058] Step 1412: Determine a reference knowledge group from the knowledge group set based on the semantic relevance between the semantic features of the question text and the semantic features of each knowledge group.

[0059] Specifically, semantic relevance is used to measure the semantic relevance between the question text and each knowledge group, that is, whether the question text has information association with the corresponding content of each knowledge group. Based on the semantic relevance between the semantic features of the question text and the semantic features of each knowledge group, the most relevant knowledge groups are selected from the knowledge group combination as reference knowledge groups, thereby ensuring that the reference knowledge groups can effectively correspond to the core content of the question text.

[0060] As an optional embodiment, after obtaining the final recalled knowledge group set Then, in order to make the question text q and the knowledge set Fully interact semantically to improve the relevance of the final search text and the question text. The embodiment of the present invention adopts the BERT model of the cross-encoder architecture as the rearrangement model, and calculates the semantic relevance score of each knowledge group in the knowledge group set based on the rearrangement model, and rearranges each knowledge group based on the semantic relevance score, and selects the most relevant knowledge groups as reference knowledge groups.

[0061] Among them, the semantic relevance score Calculated based on the following method:

[0062] in, , [CLS]q[SEP]G[SEP] represents the input sequence after concatenating the question text q and the corresponding documents G of each knowledge group, w is the weight of the linear classification layer, BERT(·)[CLS] means obtaining the hidden representation through BERT and using the [CLS] token as the semantic vector, and b is the bias term.

[0063] It should be noted that the embodiment of the present invention first determines a knowledge group set based on semantic similarity, and then filters out reference knowledge groups from the knowledge group set based on semantic relevance. The consideration is: first, by calculating the semantic similarity to filter out knowledge groups similar to the question text, the scope of candidate knowledge groups can be quickly narrowed down. After narrowing the scope, further screening is performed by semantic relevance to ensure that the knowledge groups finally selected are not only semantically similar, but also truly relevant in practical applications. It can be seen that the embodiment of the present invention can not only accurately obtain reference knowledge groups that are highly relevant to the question text through a staged screening method, but also significantly improve the overall retrieval efficiency.

[0064] As an optional embodiment, a prompt text may be constructed and input into a large language model, which then rearranges the knowledge groups and outputs knowledge groups related to the question text (i.e., reference knowledge groups) and knowledge groups not related to the question text. The prompt text example is as follows:

【Prompt: You will receive a Chinese document as input, where the paragraphs are represented by “IDXXXX: <text>"Identifier and a question text query.

[0065] Task: Find the irrelevant paragraphs in the document according to the query.

[0066] Output: Returns the IDs of paragraphs not related to the query, as shown in the example format: "Answer: [ID XXXX,...]".

[0067] Additional Considerations: Return the result as a list of IDs. Do not return other information.

[0068] query: question text

[0069] Document: ID 0001: Knowledge Group 1

[0070] ID 0002: Knowledge Group 2 (not relevant to query) ...

[0072] ID 0006: Knowledge Group 6 (not relevant to query)

[0073] Answer: [ID 0002, ID 0006]

[0074] Step 1413: construct a search prompt text based on the reference knowledge group and the question text.

[0075] Specifically, the reference knowledge group determined by the above method is highly correlated with the question text, and based on the reference knowledge group and the question text, an effective retrieval hint text can be constructed, so that knowledge retrieval can be performed accurately based on the retrieval hint text.

[0076] For example, the search prompt text It can be constructed based on the following formula:

[0077] Among them, d q is the reference knowledge group, q is the question text, TEMPLATE is the information description of the vertical field itself and the prompt words for the task goal description.

[0078] Based on any of the above embodiments, entity extraction is performed on the question text, which also includes: Perform grammatical analysis on the question text to identify the missing elements of the question text; Based on the historical dialogue text of the question text, determine the filling content corresponding to the missing elements; Rewrite the question text based on the fill-in content.

[0079] Specifically, if some elements are missing in the question text (such as missing subject, predicate, object, etc.), the semantics expressed by the question text may be ambiguous or incomplete. In this regard, the embodiment of the present invention performs grammatical analysis on the question text to determine the missing elements of the question text. The missing elements can be understood as the missing components of the question text at the grammatical structure level, such as the question text may lack a subject, predicate, object, etc.

[0080] Considering that the historical dialogue text of the question text provides the contextual information of the question text, it is possible to semantically understand the question text in combination with the historical dialogue text, determine the filling content corresponding to the missing elements, and integrate the filling content into the original question text to ensure the completeness and clarity of the rewritten question text.

[0081] For example, the question text is "How to improve the accuracy of the model?", but based on the question text alone, it is impossible to determine which type of model needs to be understood in the question text, that is, the missing element is a specific model type. For this, relevant model information can be found from historical conversations and rewritten as "How to improve the accuracy of deep learning models?".

[0082] Based on any of the above embodiments, Figure 4 It is a schematic diagram of the process of the knowledge graph construction method provided by the present invention, such as Figure 4 As shown, the method includes: Step 410: Segment the knowledge document to obtain multiple initial knowledge blocks.

[0083] Specifically, knowledge documents can be understood as knowledge texts in different fields. Considering that knowledge documents usually contain complex information and multiple topics, by segmenting knowledge texts, complex knowledge documents can be broken down into multiple initial knowledge blocks that are easier to understand and analyze, and each initial knowledge block corresponds to a part of information and topics. Among them, the knowledge document can be segmented according to the hierarchical structure of separators such as paragraph separators, line breaks, spaces, and single characters to obtain multiple initial knowledge blocks.

[0084] Step 420: Based on the semantic information of each initial knowledge block and the context information of each initial knowledge block, each initial knowledge block is split or reorganized to obtain multiple knowledge groups in the knowledge graph.

[0085] Specifically, considering the lack of understanding of the context when segmenting the knowledge document in step 410, the initial knowledge blocks obtained by segmentation may be incomplete or include multiple irrelevant content information. In this case, the embodiment of the present invention splits or reorganizes each initial knowledge block based on the semantic information of each initial knowledge block and the context information of each initial knowledge block to obtain multiple knowledge groups in the knowledge graph, thereby ensuring that the content expressed by the paragraphs corresponding to each knowledge group is different, and the content expressed by the paragraphs in the same knowledge group is the same.

[0086] Among them, when any initial knowledge block includes multiple unrelated content information, the initial knowledge block can be split; when there are multiple initial knowledge blocks expressing the same content, the multiple initial knowledge blocks can be reorganized into a knowledge group; when there is any initial knowledge block expressing incomplete content, the initial knowledge block that completes the missing content and the initial knowledge block can be reorganized into a knowledge group.

[0087] Step 430: extract triples from each knowledge group, and determine the knowledge nodes under each knowledge group based on the extraction results.

[0088] Specifically, after obtaining the knowledge groups, triples are extracted from each knowledge group to obtain entities and relationships between entities, and the extracted entities are used as knowledge nodes under the corresponding knowledge groups.

[0089] As an optional embodiment, a first extraction prompt text can be constructed based on the knowledge group, and the first extraction prompt text can be input into a large language model, and the large language model can extract entity phrases, and a second extraction prompt text can be constructed based on the extracted entity phrases, and the second extraction prompt text can be input into the large language model, and the large language model can extract entity relationships.

[0090] Among them, the first extraction prompt text example is as follows:

【Prompt: You will receive a Chinese paragraph as input.

[0091] Task: Your task is to extract named entities from a given paragraph. Respond with a JSON list of entities.

[0092] Output: Returns a list of entities in JSON format.

[0093] Reference example: Paragraph: …

[0094] Sample Knowledge Group

[0095] …

[0096] {"named_entities": ["Entity / Phrase 1", "Entity / Phrase 2", "Entity / Phrase 3", "Entity / Phrase 4", ...]}

[0097] Input: Paragraph: …

[0098] Knowledge group to be extracted

[0099] …】

[0100] The second extraction prompt text example is as follows:

【Prompt: You will receive a Chinese paragraph as input.

[0101] Task: Build an RDF(Resource Description Framework) graph from a given paragraph and a list of named entities.

[0102] Output: Returns a list of triples in JSON format, each triple represents a relationship in the RDF graph.

[0103] Additional Considerations: Each triple should contain at least one, but preferably two, of the named entities in the paragraph. Explicitly resolve pronouns to their concrete names for clarity. Convert the paragraph to a JSON dictionary containing a list of named entities and a list of triples.

[0104] Reference example: Paragraph: …

[0105] Sample Knowledge Group

[0106] …

[0107] {"named_entities": ["Entity / Phrase 1", "Entity / Phrase 2", "Entity / Phrase 3", "Entity / Phrase 4", ...]}

[0108] {

[0109] "triples": [

[0110] ["Entity / Phrase 1", "Relation 1", "Entity / Phrase 2"],

[0111] ["Entity / Phrase 3", "Relation 2", "Entity / Phrase 4"] ... ]

[0114] }

[0115] Input: Convert the paragraph into a JSON dictionary, which has a list of named entities and a list of triples.

[0116] Paragraph: …

[0117] Knowledge group to be extracted

[0118] …

[0119] {"named_entities": [entity list]}】

[0120] Figure 5 It is a schematic diagram of the process of offline construction of knowledge graph provided by the present invention, such as Figure 5 As shown, after the knowledge document is segmented according to paragraphs or lengths, multiple initial knowledge blocks (knowledge block 1, knowledge block 2, knowledge block 3, and knowledge block 4) are obtained. The multiple initial knowledge blocks are input into the large language model (LLM), and the LLM performs semantic independence preprocessing on each initial knowledge block, and splits or reorganizes the multiple initial knowledge blocks based on the knowledge checker to obtain multiple knowledge groups, such as reorganizing knowledge block 1 and knowledge block 2 into knowledge group 1, splitting knowledge block 3 into knowledge block 3_1 and knowledge block 3_2, knowledge block 3_1 constitutes knowledge group 2, and knowledge block 3_2 constitutes knowledge group 3. Then, LLM extracts triples from each knowledge group, and constructs a knowledge graph based on the extracted triples.

[0121] Based on any of the above embodiments, each initial knowledge block is split or reorganized based on the semantic information of each initial knowledge block and the context information of each initial knowledge block to obtain multiple knowledge groups in the knowledge graph, including: Construct segmentation prompt text based on each initial knowledge block, knowledge document and output knowledge group requirements; The segmentation prompt text is input into a large language model, which extracts the semantic information of each initial knowledge block and the contextual information of each initial knowledge block based on the segmentation prompt text, and splits or reorganizes each initial knowledge block based on the semantic information of each initial knowledge block and the contextual information of each initial knowledge block to obtain multiple knowledge groups in the knowledge graph.

[0122] Specifically, the output knowledge group requirements refer to the specific requirements for the organization and presentation of the knowledge group. The segmentation prompt text is used to guide the large language model to extract the semantic information of each initial knowledge block and the context information of each initial knowledge block, and based on the semantic information of each initial knowledge block and the context information of each initial knowledge block, split or reorganize each initial knowledge block to obtain multiple knowledge groups in the knowledge graph.

[0123] The segmentation prompt text example is as follows: 【Prompt: You will receive a Chinese document as input, where the knowledge blocks are represented by "IDXXXX: <text>” logo.

[0124] Task: Find a knowledge block (not the first one) where the content has changed significantly compared to the previous ones.

[0125] Output: Returns the ID of the knowledge block with the content offset, as shown in the example format: "Answer: IDXXXX".

[0126] Additional Considerations: Avoid knowledge groups that are too long. Strike a good balance between identifying content changes and keeping the knowledge group manageable.

[0127] Document: ID 0001: Knowledge Block 1

[0128] ID 0002: Knowledge Block 2 ...

[0130] ID 0006: Knowledge Block 6 (Semantic Content Offset)

[0131] ID 0007: Knowledge Block 7 ...

[0133] Answer: ID 0006

[0134] Among them, in order to avoid inputting too many initial knowledge blocks into LLM at one time, which may affect the reasoning accuracy of LLM due to too much context, a threshold θ (such as θ=0) can be set to ensure that 10 groups of initial knowledge blocks are input into LLM each time. After LLM splits or reorganizes the 10 groups of initial knowledge blocks, the next batch of 10 groups of initial knowledge blocks are input into LLM.

[0135] Based on any of the above embodiments, triples are extracted from each knowledge group, and the process also includes: Based on the semantic information of each knowledge group, knowledge detection is performed on each knowledge group.

[0136] Specifically, considering that a knowledge group may contain common sense erroneous knowledge, logically contradictory knowledge or unsafe knowledge, in order to accurately perform knowledge retrieval, the embodiment of the present invention performs knowledge detection on each knowledge group based on the semantic information of each knowledge group after extracting triples from each knowledge group, so as to filter out common sense erroneous knowledge, logically contradictory knowledge or unsafe knowledge.

[0137] As an optional embodiment, a knowledge detection prompt text may be constructed and input into a large language model to guide the large language model to perform knowledge detection and filter out common sense erroneous knowledge, logically contradictory knowledge or unsafe knowledge.

[0138] Among them, the knowledge detection prompt text example is as follows: 【Prompt: You will receive a Chinese document as input, which contains multiple knowledge groups, represented by "IDXXXX: <text>” for identification.

[0139] Task: Find knowledge groups that contain common sense errors, logical contradictions, and sensitive, illegal, false, discriminatory, offensive, malicious code, or extreme speech content.

[0140] Output: Returns the IDs of knowledge groups that contain common sense errors, logical contradictions, and sensitive, illegal, false, discriminatory, offensive, malicious code, or extreme speech content, as shown in the sample format: "Answer: [ID XXXX, IDXXXX, ...]".

[0141] Additional Considerations: For two or more logically contradictory pieces of knowledge, keep the correct one and return the response in a list format. Do not output other content.

[0142] Document: ID 0001: Knowledge Block 1

[0143] ID 0002: Knowledge Block 2 ...

[0145] ID 0006: Knowledge Block 6

[0146] ID 0007: Knowledge Block 7 (Content Error & Unsafe Content)

[0147] Answer: [ID 0007]

[0148] Figure 6 This is the second flow chart of the knowledge retrieval method provided by the present invention. Figure 6 As shown, first, the knowledge graph is constructed offline: after the knowledge document is segmented according to paragraphs or length, multiple initial knowledge blocks (knowledge block 1, knowledge block 2, knowledge block 3 and knowledge block 4) are obtained. The multiple initial knowledge blocks are input into the large language model (LLM), and the LLM performs semantic independence preprocessing on each initial knowledge block, and splits or reorganizes the multiple initial knowledge blocks based on the knowledge checker to obtain multiple knowledge groups, such as reorganizing knowledge block 1 and knowledge block 2 into knowledge group 1, splitting knowledge block 3 into knowledge block 3_1 and knowledge block 3_2, knowledge block 3_1 constitutes knowledge group 2, and knowledge block 3_2 constitutes knowledge group 3. Then, LLM extracts triples from each knowledge group, and constructs a knowledge graph based on the extracted triples.

[0149] Next, enter the online reasoning, rewrite the current question, extract the question entity from the rewritten question, and use the PPR algorithm in the knowledge graph based on the question entity to determine the first knowledge group set. At the same time, the rewritten question is vectorized, the semantic features of the question are extracted, and the semantic similarity between the rewritten question and each knowledge group is determined based on the semantic features to determine the second knowledge group set.

[0150] The first knowledge group set and the second knowledge group set are rearranged, and a reference knowledge group with a high relevance to the current question is selected. A search prompt text is constructed based on the reference knowledge group and the current question, and the search prompt text is input into the LLM to output a response corresponding to the current question.

[0151] The knowledge retrieval device provided by the present invention is described below. The knowledge retrieval device described below and the knowledge retrieval method described above can be referenced to each other.

[0152] Based on any of the above embodiments, Figure 7 is a schematic diagram of the structure of the knowledge retrieval device provided by the present invention, such as Figure 7 As shown, the device comprises: An entity extraction unit 710 is used to extract entities from the question text to obtain question entities; A first determining unit 720, configured to determine a first set of knowledge groups aligned with the question entity from the knowledge graph based on the semantic similarity between the question entity and each knowledge node in the knowledge graph; A second determining unit 730 is used to determine a second set of knowledge groups from the knowledge graph based on the semantic similarity between the question text and each knowledge group in the knowledge graph, wherein the knowledge graph includes multiple knowledge groups, and the correlation between each knowledge node in the same knowledge group is greater than a threshold; The knowledge retrieval unit 740 is used to perform knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text.

[0153] Based on any of the above embodiments, knowledge retrieval is performed based on the first knowledge group set, the second knowledge group set, and the question text, including: Constructing a search prompt text based on the first knowledge group set, the second knowledge group set and the question text; The search prompt text is input into a large language model, which performs knowledge retrieval to obtain the answer text corresponding to the question text.

[0154] Based on any of the above embodiments, constructing a search prompt text based on the first knowledge group set, the second knowledge group set and the question text includes: Extracting semantic features of the question text and semantic features of each knowledge group in the knowledge group set, where the knowledge group set includes a first knowledge group set and a second knowledge group set; Based on the semantic relevance between the semantic features of the question text and the semantic features of each knowledge group, a reference knowledge group is determined from the knowledge group set; Construct search prompt text based on reference knowledge group and question text.

[0155] Based on any of the above embodiments, entity extraction is performed on the question text, which also includes: Perform grammatical analysis on the question text to identify the missing elements of the question text; Based on the historical dialogue text of the question text, determine the filling content corresponding to the missing elements; Rewrite the question text based on the fill-in content.

[0156] Based on any of the above embodiments, the knowledge graph is constructed based on the following steps: Split the knowledge document to obtain multiple initial knowledge blocks; Based on the semantic information of each initial knowledge block and the context information of each initial knowledge block, each initial knowledge block is split or reorganized to obtain multiple knowledge groups in the knowledge graph; Triples are extracted for each knowledge group, and knowledge nodes under each knowledge group are determined based on the extraction results.

[0157] Based on any of the above embodiments, each initial knowledge block is split or reorganized based on the semantic information of each initial knowledge block and the context information of each initial knowledge block to obtain multiple knowledge groups in the knowledge graph, including: Construct segmentation prompt text based on each initial knowledge block, knowledge document and output knowledge group requirements; The segmentation prompt text is input into a large language model, which extracts the semantic information of each initial knowledge block and the contextual information of each initial knowledge block based on the segmentation prompt text, and splits or reorganizes each initial knowledge block based on the semantic information of each initial knowledge block and the contextual information of each initial knowledge block to obtain multiple knowledge groups in the knowledge graph.

[0158] Based on any of the above embodiments, triples are extracted from each knowledge group, and the process also includes: Based on the semantic information of each knowledge group, knowledge detection is performed on each knowledge group.

[0159] Figure 8 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 8 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the knowledge retrieval method, which includes: extracting entities from the question text to obtain question entities; determining a first knowledge group set aligned with the question entity from the knowledge graph based on the semantic similarity between the question entity and each knowledge node in the knowledge graph; determining a second knowledge group set from the knowledge graph based on the semantic similarity between the question text and each knowledge group in the knowledge graph, wherein the knowledge graph includes multiple knowledge groups, and the correlation between each knowledge node in the same knowledge group is greater than a threshold; performing knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text.

[0160] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0161] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the knowledge retrieval method provided by the above methods, which method includes: performing entity extraction on the question text to obtain the question entity; based on the semantic similarity between the question entity and each knowledge node in the knowledge graph, determining a first knowledge group set aligned with the question entity from the knowledge graph; based on the semantic similarity between the question text and each knowledge group in the knowledge graph, determining a second knowledge group set from the knowledge graph, the knowledge graph including multiple knowledge groups, and the correlation between each knowledge node in the same knowledge group is greater than a threshold; performing knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text.

[0162] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the knowledge retrieval method provided by the above-mentioned methods, the method comprising: performing entity extraction on a question text to obtain a question entity; determining a first knowledge group set aligned with the question entity from the knowledge graph based on the semantic similarity between the question entity and each knowledge node in the knowledge graph; determining a second knowledge group set from the knowledge graph based on the semantic similarity between the question text and each knowledge group in the knowledge graph, the knowledge graph comprising multiple knowledge groups, and the correlation between each knowledge node in the same knowledge group being greater than a threshold; performing knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text.

[0163] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0164] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0165] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.< / text> < / text> < / text>

Claims

1. A knowledge retrieval method, characterized in that: include: Perform entity extraction on the question text to obtain question entities; Based on the semantic similarity between the question entity and each knowledge node in the knowledge graph, determining a first knowledge group set aligned with the question entity from the knowledge graph; Based on the semantic similarity between the question text and each knowledge group in the knowledge graph, determining a second knowledge group set from the knowledge graph, wherein the knowledge graph includes a plurality of the knowledge groups, and the correlation between each knowledge node in the same knowledge group is greater than a threshold; Knowledge retrieval is performed based on the first knowledge group set, the second knowledge group set and the question text.

2. The knowledge retrieval method according to claim 1, characterized in that: The performing knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text includes: Constructing a search prompt text based on the first knowledge group set, the second knowledge group set and the question text; The search prompt text is input into a large language model, and the large language model performs knowledge search to obtain an answer text corresponding to the question text.

3. The knowledge retrieval method according to claim 2, characterized in that: The step of constructing a search prompt text based on the first knowledge group set, the second knowledge group set and the question text includes: Extracting semantic features of the question text and semantic features of each of the knowledge groups in a knowledge group set, wherein the knowledge group set includes the first knowledge group set and the second knowledge group set; Determining a reference knowledge group from the knowledge group set based on the semantic relevance between the semantic features of the question text and the semantic features of each of the knowledge groups; The search prompt text is constructed based on the reference knowledge group and the question text.

4. The knowledge retrieval method according to any one of claims 1 to 3, characterized in that: The entity extraction of the question text also includes: Performing grammatical analysis on the question text to determine missing elements of the question text; Determining the filling content corresponding to the missing element based on the historical dialogue text of the question text; Based on the fill-in content, the question text is rewritten.

5. The knowledge retrieval method according to any one of claims 1 to 3, characterized in that: The knowledge graph is constructed based on the following steps: Split the knowledge document to obtain multiple initial knowledge blocks; Based on the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks, each of the initial knowledge blocks is split or reorganized to obtain a plurality of the knowledge groups in the knowledge graph; Triples are extracted from each of the knowledge groups, and knowledge nodes under each of the knowledge groups are determined based on the extraction results.

6. The knowledge retrieval method according to claim 5, characterized in that: The step of splitting or reorganizing each of the initial knowledge blocks based on the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks to obtain a plurality of the knowledge groups in the knowledge graph includes: Constructing segmentation prompt text based on each of the initial knowledge blocks, the knowledge documents and the output knowledge group requirements; The segmentation prompt text is input into a large language model, and the large language model extracts the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks based on the segmentation prompt text, and splits or reorganizes each of the initial knowledge blocks based on the semantic information of each of the initial knowledge blocks and the context information of each of the initial knowledge blocks to obtain the multiple knowledge groups in the knowledge graph.

7. The knowledge retrieval method according to claim 5, characterized in that: The extracting of triples from each of the knowledge groups also includes: Based on the semantic information of each of the knowledge groups, knowledge detection is performed on each of the knowledge groups.

8. A knowledge retrieval device, characterized in that: include: An entity extraction unit is used to extract entities from question text to obtain question entities; A first determining unit, configured to determine, from the knowledge graph, a first set of knowledge groups aligned with the question entity based on the semantic similarity between the question entity and each knowledge node in the knowledge graph; A second determination unit is used to determine a second set of knowledge groups from the knowledge graph based on the semantic similarity between the question text and each knowledge group in the knowledge graph, wherein the knowledge graph includes a plurality of the knowledge groups, and the correlation between each of the knowledge nodes in the same knowledge group is greater than a threshold; The knowledge retrieval unit is used to perform knowledge retrieval based on the first knowledge group set, the second knowledge group set and the question text.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the knowledge retrieval method according to any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the knowledge retrieval method according to any one of claims 1 to 7 is implemented.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the knowledge retrieval method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Question and answer knowledge retrieval method, device and equipment based on graph embedding

    CN113947084A

  • Knowledge question and answer method and device, electronic equipment and storage medium

    CN118228824A

Cited By

  • Knowledge graph construction method and device and medium

    CN120104608A

  • Knowledge graph retrieval reasoning method and system based on big language model enhancement

    CN120123487A