Intelligent question and answer method and device
By combining the two-layer knowledge graph and RAG technology, traditional RAG technology solves the problems of insufficient global query focus and difficult to handle complex relationship question-and-answers in intelligent question-and-answers, achieving higher accuracy and comprehensiveness of intelligent question-and-answers.
Patent Information
- Application Number
- CN202411978067.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2044-12-30
AI Technical Summary
Traditional RAG technology has insufficient global query focus and difficulty in dealing with complex relationship question-and-answer in the field of intelligent question-and-answer.
By combining the two-layer knowledge graph with RAG technology, the complex relationship query ability of the two-layer knowledge graph and the global perspective of community abstracts can be obtained from the vector knowledge base, and the community summary and sub-graphic text description will be generated, and the global answer will be finally generated.
It improves the accuracy and comprehensiveness of RAG technology in intelligent question-and-answer, can more effectively handle complex relationship question-and-answer and provide answers from a global perspective.
Smart Images

Figure CN119917622A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of large language models, and more specifically, to an intelligent question answering method and device. Background Art
[0002] Intelligent question answering is one of the important application areas of large language models (LLM). Large language models with tens of billions of parameters trained by massive data can fully learn the semantic information and contextual relationships of texts, and deeply understand and process natural language texts. Due to the limitations of training data sets, large language models have certain limitations in timeliness and accuracy.
[0003] Therefore, a new intelligent question answering method and device is needed. Summary of the invention
[0004] The embodiments of the present application provide an intelligent question-answering method and device, which can provide a global perspective on community summaries through a two-layer knowledge graph, thereby improving the accuracy and comprehensiveness of RAG technology.
[0005] According to the first aspect of the present application, a smart question and answer method is provided, comprising: receiving an input text; obtaining the top N entities with the highest similarity from a vector knowledge base based on the input text, wherein N is an integer greater than or equal to 1; obtaining corresponding N communities from a top-level knowledge graph in a double-layer knowledge graph based on the top N entities; generating multiple intermediate input texts by a smart question and answer big language model based on the input text and the community summaries of the N communities; obtaining corresponding N subgraphs from a bottom-level knowledge graph in the double-layer knowledge graph based on the top N entities; generating text descriptions of the N subgraphs by the smart question and answer big language model; and generating a global answer by the smart question and answer big language model based on the input text, the multiple intermediate input texts, and the text descriptions of the N subgraphs.
[0006] According to an embodiment of the first aspect of the present application, obtaining the top N entities with the highest similarity from the vector knowledge base based on the input text includes: vectorizing the input text to obtain vectorized input text; and performing similarity calculation in the vector knowledge base based on the vectorized input text to obtain the top N entities with the highest similarity.
[0007] According to an embodiment of the first aspect of the present application, generating multiple intermediate input texts by the intelligent question and answer large language model based on the input text and the community summaries of the N communities includes: generating corresponding N intermediate answers and usefulness scores by the intelligent question and answer large language model based on the input text and the community summaries of the N communities; based on the usefulness scores, obtaining the first K intermediate answers among the N intermediate answers, and concatenating the first K intermediate answers in descending order of usefulness scores and dividing them into the multiple intermediate input texts according to a fixed string length.
[0008] According to an embodiment of the first aspect of the present application, generating a text description of the N subgraphs by the intelligent question and answer large language model includes: generating a text description of the N subgraphs by the intelligent question and answer large language model based on entities and relationships in each subgraph.
[0009] According to an embodiment of the first aspect of the present application, the two-layer knowledge graph is automatically created by the intelligent question and answer large language model using a first prompt template, wherein the first prompt template includes task objectives, execution steps, and context examples.
[0010] According to an embodiment of the first aspect of the present application, the top-level knowledge graph is automatically created by the intelligent question and answer big language model using the first prompt template based on a user predefined data set, and wherein the bottom-level knowledge graph is automatically created by the intelligent question and answer big language model using the first prompt template based on a professional standard data set.
[0011] According to an embodiment of the first aspect of the present application, the top-level knowledge graph includes entities, relationships and communities, the bottom-level knowledge graph includes entities and relationships, and wherein the entities in the top-level knowledge graph are linked to the entities in the bottom-level knowledge graph by the intelligent question-and-answer large language model based on similarity calculation.
[0012] According to an embodiment of the first aspect of the present application, the entity includes an entity name, an entity type and an entity description, the relationship includes a source entity, a target entity, a relationship description and a relationship weight, and the community is a set of entities and relationships obtained by aggregating the entities and relationships in the top-level knowledge graph based on a community clustering algorithm.
[0013] According to an embodiment of the first aspect of the present application, the community summary of each community in the top-level knowledge graph is automatically created by the intelligent question and answer large language model using a second prompt template, wherein the second prompt template includes a task objective and a community summary format.
[0014] According to an embodiment of the first aspect of the present application, the vector knowledge base is created in the following manner: vectorizing the entities, relationships, and communities in the top-level knowledge graph to obtain vectorized entities, vectorized relationships, and vectorized communities, and wherein the vector knowledge base includes the entities, the relationships, the communities, the vectorized entities, the vectorized relationships, and the vectorized communities.
[0015] According to the second aspect of the present application, an intelligent question-answering device is provided, comprising: a processor, and a memory storing instructions, wherein when the instructions are executed by the processor, the processor executes the method of the first aspect of the present application.
[0016] According to a third aspect of the present application, a computer-readable storage medium is provided, on which instructions are stored. When the instructions are executed by a computer, the computer executes the method of the first aspect of the present application.
[0017] According to the intelligent question-answering method and device of the embodiment of the present application, by obtaining the first N entities with the highest similarity to the input text from the vector knowledge base, the corresponding N communities can be obtained from the top knowledge graph in the double-layer knowledge graph, and multiple intermediate input texts can be generated based on the input text and the community summaries of the N communities. In addition, N subgraphs corresponding to the first N entities can be obtained from the bottom knowledge graph in the double-layer knowledge graph, and a text description of the N subgraphs can be generated. On this basis, a global answer can be generated based on the input text, multiple intermediate input texts, and the text description of the N subgraphs. By combining the double-layer knowledge graph with RAG technology, utilizing the complex relationship query capabilities of the double-layer knowledge graph and the global perspective of the community summary, the deficiencies of traditional RAG technology in global query-focused question-answering in the field of intelligent question-answering can be made up, and the accuracy and comprehensiveness of intelligent question-answering of RAG technology can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the drawings without paying creative work.
[0019] Figure 1 is a flow chart of an intelligent question-answering method according to an embodiment of the present application; and
[0020] Figure 2 It is a schematic diagram of the hardware structure of the intelligent question-answering device according to an embodiment of the present application. DETAILED DESCRIPTION
[0021] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only configured to explain the present application and are not configured to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.
[0022] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0023] The features and exemplary embodiments of various aspects of the present application will be described in detail below.In addition, the features, structures, or characteristics described below may be combined in any suitable manner in one or more embodiments.
[0024] Intelligent question answering is one of the important application areas of large language models (LLM). By training large language models with tens of billions of parameters using massive data, they can fully learn the semantic information and contextual relationships of texts, and deeply understand and process natural language texts.
[0025] Retrieval-Augmented Generation (RAG) technology converts input text into vectorized input text, retrieves text blocks related to the input text from the vector knowledge base, combines them with the input text, and inputs them into the large language model to generate an answer.
[0026] However, traditional RAG technology has the following defects: (1) It focuses more on local text retrieval and still has shortcomings in the query-focused summarization task (QFS) of the entire document, lacking a global perspective for answering questions; (2) It is difficult to answer complex relational questions and the depth of knowledge understanding is insufficient.
[0027] Knowledge graphs can extract and integrate knowledge texts into graphs, and can apply graph theory algorithms to provide global understanding of knowledge and complex multi-hop relationship queries. Therefore, the inventors of this application thought of combining knowledge graphs with RAG technology to make up for the shortcomings of traditional RAG technology in global query-focused question and answer in the field of intelligent question and answer.
[0028] The embodiments of the present application provide an intelligent question-answering method and device, which can provide a global perspective on community summaries through a two-layer knowledge graph, thereby improving the accuracy and comprehensiveness of RAG technology.
[0029] Figure 1 is a flow chart of an intelligent question-answering method according to an embodiment of the present application. Figure 1 As shown, the intelligent question-answering method according to an embodiment of the present application includes the following steps S110 to S170.
[0030] S110: receiving input text.
[0031] In one embodiment, the input text may be a question text of a user.
[0032] S120: Based on the input text, obtain the top N entities with the highest similarity from the vector knowledge base, where N is an integer greater than or equal to 1.
[0033] In one embodiment, step S120 may include: performing vectorization processing on the input text to obtain vectorized input text; performing similarity calculation in a vector knowledge base based on the vectorized input text to obtain top N entities with the highest similarity.
[0034] For example, the input text may be vectorized using a text vector representation model to obtain a vectorized input text. For example, the text vector representation model may be a BGE-M3 model, a BGE-small model, a BGE-large model, a TFIDF model, a word-to-vector model, etc. This application does not impose any restrictions on this.
[0035] Furthermore, the vectorized input text can be compared with the entities in the vector knowledge base (for example, similarity calculation is performed), so as to obtain the top N entities in the vector knowledge base that are most similar to the vectorized input text. Here, N can be an integer greater than or equal to 1, for example, 2, 4, 6, etc. In addition, similarity calculation can include, for example, calculating cosine similarity, calculating Euclidean similarity, calculating Euclidean distance, calculating Manhattan distance, etc. This application does not impose any restrictions on this.
[0036] S130: Obtain corresponding N communities from the top-level knowledge graph in the double-layer knowledge graph based on the first N entities.
[0037] In one embodiment, the dual-layer knowledge graph includes a top-layer knowledge graph and a bottom-layer knowledge graph. In one embodiment, the top-layer knowledge graph includes entities, relationships, and communities, and the bottom-layer knowledge graph includes entities and relationships.
[0038] In one embodiment, an entity includes an entity name, an entity type, and an entity description. For example, the format of an entity can be: ("entity" <|><entity_name> <|><entity_type> <|><entity_description> ).
[0039] In one embodiment, a relationship includes a source entity, a target entity, a relationship description, and a relationship weight. For example, the format of a relationship may be: ("relationship" <|><source_entity> <|><target_entity> <|><relationship_description> <|><relationship_strength> ).
[0040] In one embodiment, the two-layer knowledge graph is automatically created by the intelligent question-answering large language model using a first prompt template, wherein the first prompt template includes a task goal, execution steps, and context examples.
[0041] For example, the intelligent question-answering large language model may be a general large language model, which may include, for example, GLM1, GLM2, GLM3, GLM4, QWEN, etc. This application does not impose any limitation on this.
[0042] For example, the first prompt template may include a task goal (Goal) to inform the intelligent question-answering language model of the task goal to be performed. For example, the task goal of the first prompt template may be to extract different types of entities from the text, as well as the relationship between entities. The pseudo code of the task goal is as follows:
[0043] -Goal-
[0044] Given a text document that is potentially relevant to this activity and a list of entity types, identify all entities of those types from the text and all relationships among the identified entities.
[0045] For example, the first prompt template may include an execution step for informing the intelligent question-answering large language model of the standard steps for extracting entities and relations. The pseudo code of the execution step is as follows:
[0046] -Steps-
[0047] 1.Identify all entities.For each identified entity, extract the following information:
[0048] -entity_name: Name of the entity, capitalized
[0049] -entity_type: One of the following types: [hs_code, goods, character]
[0050] -entity_description:Comprehensive description of the entity′sattributes and activities Format each entity as(″entity″<|> <entity-name><|><entity_type><|> <entity-description>
[0051] 2.From the entities identified in step 1,identify allpairs of(source_entity,target_entity)that are*clearly related*to each other.
[0052] For each pair of related entities,extract the following information:
[0053] -source_entity:name of the source entity,as identified in step 1
[0054] -target_entity:name of the target entity,as identified in step 1
[0055] -relationship_description:explanation as to why you think the sourceentity and the target entity are related to each other
[0056] -relationship_strength:a numeric score indicating strength of therelationship between the source entity and target entity
[0057] Format each relationship as(″relationship″<|><source_entity><|><target_entity><|><relationship_description><|><relationship_strength>)
[0058] 3.Return output as a single list of all the entities and relationships identified in steps 1 and 2.Use**##**as the list delimiter.
[0059] 4.when finished, output<|COMPLETE|>|
[0060] For example, the first prompt template may include a context example to inform the intelligent question-answering large language model of entity and relationship examples. The pseudo code of the context example is as follows:
[0061] Example 1:
[0062] Entity_types: [hs_code, goods, character]
[0063] Text: The corresponding commodity for fresh coconuts with inner shells (endocarps) is coconut, and the corresponding first-level subheading for coconut is 08011. Because it is preserved fresh and processed by removing the inner shell, the subheading clause is queried and this commodity should be classified into 0801120000.
[0064] #############
[0065] Output:
[0066] ("entity" <|> "08011" <|> "hscode" <|> "08011 is a first-level sub-item, corresponding to coconut, and belongs to the organizational classification. ")##
[0067] ("entity" <|> "0801120000" <|> "hs_code" <|> "0801120000 is a second-level sub-heading under the first-level sub-heading 08011, belonging to the tissue classification, the storage method is fresh, and the processing method is to remove the inner shell of coconuts. ")##
[0068] ("entity" <|>"Coconut" <|>"goods" <|>"Coconut is a kind of goods name of the first-level subheading 08011, which belongs to the goods example. ")##
[0069] ("entity" <|> "fresh" <|> "character" <|> "Coconut can be preserved fresh, which is a characteristic of coconut.")##
[0070] ("entity" <|>"Fresh coconut with inner shell (endocarp)" <|>"goods" <|>"Coconuts that are stored fresh and processed with inner shell (endocarp) not removed are a name of coconut goods with more detailed characteristics. ")##
[0071] ("entity" <|>"removing the inner shell (endocarp)" <|>"character" <|>"the coconut can be processed by removing the inner shell, which is a characteristic of coconut. ")##
[0072] ("relationship"<|>"0801120000"<|>"08011"<|>"Second-level sub-item 08011100 is a specific sub-item under item 08011, indicating the hierarchical inclusion relationship between them. ″<|>7)##
[0073] ("relationship" <|> "Coconut" <|> "08011" <|> "Coconut is a commodity name of the first-level subheading 08011, explain the example relationship between them. " <|> 8)##
[0074] ("relationship" <|> "fresh" <|> "coconut" <|> "this is a way to preserve coconuts, it is a characteristic of coconuts" <|> 8)##
[0075] ("relationship" <|> "dry" <|> "coconut" <|> "this is a way to preserve coconuts, it is a characteristic of coconuts" <|> 8)##
[0076] ("relationship" <|> "Fresh coconuts in shell (endocarp)" <|> "0801120000" <|> "Coconuts in shell (endocarp)" is a commodity name under subheading 08011200. Explain the relationship between them. " <|> 8) <|COMPLETE|>
[0077] As an example, the above-mentioned first prompt template is concatenated with the data set used to extract the knowledge graph, and then input into the intelligent question-answering large language model to achieve automatic extraction of entities and relationships.
[0078] In one embodiment, the text of the data set used to extract the knowledge graph can be divided to obtain multiple text units (tokens). For example, any appropriate word segmenter (e.g., GLM word segmentation tool, LLAMAINDEX, etc.) can be used to segment the text. Further, the above-mentioned first prompt template and the text unit can be text spliced and input into the intelligent question and answer large language model to generate entities and relationships. In addition, the generated entities and relationships can also be semantically disambiguated. For example, different texts pointing to the same entity in multiple text units can be merged. In this way, the final entities and relationships can be formed.
[0079] In one embodiment, the top-level knowledge graph is automatically created by the intelligent question-answering large language model using the first prompt template based on the user predefined data set. For example, the user predefined data set can be a document provided by the user. For example, taking the commodity tax number knowledge graph as an example, the user predefined data set can include declaration data, manual inspection data, etc. from the customs clearance operation system, as well as administrative ruling articles, classified question-and-answer articles, classified professional certification articles, etc. from the website of the General Administration of Customs. For another example, taking the medical knowledge graph as an example, the user predefined data set can include hospital outpatient records, prescription records, medical papers, etc.
[0080] In one embodiment, the underlying knowledge graph is automatically created by the intelligent question-answering language model using the first prompt template based on the professional standard data set. For example, the professional standard data set can be professional industry standard data. For example, taking the commodity tax number knowledge graph as an example, the professional standard data set can include "Import and Export Tariffs", "Import and Export Tariff Commodity and Item Notes", "Import and Export Tariff National Sub-item Notes", etc. For another example, taking the medical knowledge graph as an example, the professional standard data set can include medical dictionaries, medical textbooks, etc.
[0081] In one embodiment, entities in the top-level knowledge graph are linked to entities in the underlying knowledge graph by the intelligent question-answering large language model based on similarity calculation. For example, the entities in the top-level knowledge graph and the entities in the underlying knowledge graph can be vectorized respectively, and then similarity calculations are performed to obtain the correlation between the entities in the top-level knowledge graph and the entities in the underlying knowledge graph. As an example, cosine similarity can be calculated, for example, according to the value definition of cosine similarity: very relevant (>0.95), relatively relevant (>0.9), generally relevant (≥0.8), irrelevant (<0.8). Thus, the entities in the top-level knowledge graph can be linked to the entities in the underlying knowledge graph through the intelligent question-answering large language model to form a double-layer knowledge graph.
[0082] In one embodiment, a community is a collection of entities and relationships obtained by aggregating entities and relationships in the top-level knowledge graph based on a community clustering algorithm. For example, a community clustering algorithm can be applied to the top-level knowledge graph to divide the top-level knowledge graph into multiple communities at different levels. It should be noted that the bottom-level knowledge graph provides dictionary-like professional knowledge and legal and regulatory knowledge, which is used for link subgraph retrieval of entities in the top-level knowledge graph. Therefore, there is no need to cluster the bottom-level knowledge graph, that is, the bottom-level knowledge graph does not include communities.
[0083] In one embodiment, the top-level knowledge graph may have 4 levels of communities, for example, c0 community, c1 community, c2 community and c3 community, where c0 community is the highest level community, c3 community is the lowest level community, and the lower level community is a sub-community of the higher level community, for example, c2 community is a sub-community of c1 community. It is worth noting that the top-level knowledge graph may have any number of levels of communities, and this application does not impose any restrictions on this.
[0084] In one embodiment, the input text may include information specifying the community level. For example, the user may specify the community level of the top-level knowledge graph in the question text, for example, the c1 community. In this case, the corresponding N communities obtained in step S120 are communities of the specified level, for example, the c1 community. In addition, the input text may not include information specifying the community level, in which case the corresponding N communities obtained in step S120 are the default highest-level communities, for example, the c0 community.
[0085] In one embodiment, the community clustering algorithm may be any suitable algorithm for community clustering of knowledge graphs, and the present application does not impose any restrictions on this. For example, the community clustering algorithm may be the Louvain algorithm, which performs community division based on the principle of maximizing modularity. For example, the modularity calculation formula is as follows:
[0086]
[0087] Among them, Q is the modularity value, m is the number of edges, and k is i is the node degree of node i, k j is the node degree of node j, A is the adjacency matrix, c is the community, when the communities of node i and node j are the same, δ(c i ,c j )=1, otherwise, δ(c i ,c j )=0.
[0088] In one embodiment, the community summary of each community in the top-level knowledge graph is automatically created by the intelligent question-answering language model using a second prompt template, wherein the second prompt template includes a task goal and a community summary format.
[0089] For example, the second prompt template may include a task goal (Goal) to inform the intelligent question-answering language model of the task goal to be performed. For example, the task goal of the first prompt template may be to generate a community summary. The pseudo code of the task goal is as follows:
[0090] #Goal
[0091] Write a comprehensive report of a community, given a list of entities that belong to the community as well as their relationships and optional associated claims. The report will be used to inform decision-makers aboutinformation associated with the community and their potential impact. The content of this report includes an overview of the community's key entities, their legal compliance, technical capabilities, reputation, and noteworthy claims.
[0092] For another example, the second prompt template may include a community summary format, which is used to inform the intelligent question-answering language model of the community summary format to be output, wherein the community summary format includes a community title, a community introduction, and a key point description. For example, the community summary may include: (1) a community title (TITLE), which is as concise as possible; (2) a community introduction (SUMMARY), which summarizes the overall structure of the community, explains the relevant important information of the entity, and the relationship between the entities; (3) a key point description (DETAILED FINDINGS), which describes 5-10 key points of the community in detail, and each key point has an introduction. The pseudo code of the community summary format is as follows:
[0093]
[0094] As an example, the above second prompt template is combined with the entities and relationships of the community for text splicing and input into the intelligent question-answering language model to realize the automatic generation of community summaries. The community summary can provide full coverage of the input documents it represents and can provide an index to the underlying knowledge graph. Therefore, community clustering can abstract and summarize text information and provide knowledge understanding from a global perspective.
[0095] In one embodiment, a vector knowledge base is created by vectorizing entities, relationships, and communities in a top-level knowledge graph to obtain vectorized entities, vectorized relationships, and vectorized communities, and wherein the vector knowledge base includes entities, relationships, communities, vectorized entities, vectorized relationships, and vectorized communities.
[0096] For example, the text vector representation model can be used to vectorize the entities, relationships, and communities in the top-level knowledge graph to obtain vectorized entities, vectorized relationships, and vectorized communities. For example, the text vector representation model can be a BGE-M3 model, a BGE-small model, a BGE-large model, a TFIDF model, a word-to-vector model, and the like. This application does not impose any restrictions on this.
[0097] In one embodiment, the vector knowledge base may use any suitable database. This application does not impose any restrictions on this. For example, the Lucene database may be used as a database for vector storage, which may provide an efficient similar vector retrieval function, etc.
[0098] S140: Generate multiple intermediate input texts by the intelligent question-answering large language model based on the input text and the community summaries of N communities.
[0099] In one embodiment, step S140 may include: generating corresponding N intermediate answers and usefulness scores by the intelligent question-answering large language model based on the input text and the community summaries of N communities; based on the usefulness scores, obtaining the first K intermediate answers among the N intermediate answers, and concatenating the first K intermediate answers in descending order of usefulness scores and dividing them into multiple intermediate input texts of fixed length.
[0100] For example, the community summary of each community in N communities can be spliced with the input text and input into the intelligent question-answering language model to generate the corresponding intermediate answer and usefulness score. In one embodiment, the usefulness score can be a score given by the intelligent question-answering language model to evaluate the intermediate answer. For example, the usefulness score can include 1-10 points, where 10 points means that the intermediate answer is the most useful and 1 point means that the intermediate answer is useless.
[0101] For another example, the usefulness scores of N intermediate answers can be sorted in descending order to obtain the top K intermediate answers with the highest scores among the N intermediate answers. Then, the top K intermediate answers can be concatenated in descending order of scores and divided into multiple intermediate input texts according to a fixed length. For example, when the segmentation length is set to 300 tokens (token is the basic unit of input of a large language model, indicating the smallest unit into which text data is divided), each intermediate input text is a string consisting of 300 tokens.
[0102] S150: Obtain corresponding N subgraphs from the bottom layer knowledge graph in the double-layer knowledge graph based on the first N entities.
[0103] In one embodiment, the underlying knowledge graph subgraph corresponding to each of the first N entities can be obtained based on the link relationship between the entity in the top knowledge graph and the entity in the bottom knowledge graph. In one embodiment, it is known that entity A in the top knowledge graph is linked to entity A in the bottom knowledge graph according to similarity calculation. ′ , assuming that the subgraph is a three-hop subgraph, then the underlying knowledge graph subgraph of entity A is: entity A ′ →Entity B→Entity C→Entity D, which includes four entities and three relationships. In addition, the subgraph can be any multi-hop subgraph, and this application does not impose any limitation on this.
[0104] S160: Generate text descriptions of N subgraphs using the intelligent question-answering large language model.
[0105] In one embodiment, for each of the N subgraphs, the entities and relations in the subgraph may be input into the intelligent question-answering language model to generate a text description of the subgraph. For example, the text description may be a text concatenation of the entity name and entity description of the entity in the subgraph and the source entity, target entity, and relation description of the relation.
[0106] S170: Based on the input text, multiple intermediate input texts, and the text descriptions of the N subgraphs, a global answer is generated by the intelligent question-answering large language model.
[0107] In one embodiment, the input text, multiple intermediate input texts, and the corresponding text descriptions of the N subgraphs can be input together into the intelligent question-answering language model to generate a global answer. For example, based on the link subgraph of the double-layer knowledge graph and the community summary of the top-level knowledge graph, the global answer can have a global perspective and thus can have higher accuracy and comprehensiveness.
[0108] According to the intelligent question-answering method of the embodiment of the present application, by obtaining the first N entities with the highest similarity to the input text from the vector knowledge base, the corresponding N communities can be obtained from the top knowledge graph in the double-layer knowledge graph, and multiple intermediate input texts can be generated based on the input text and the community summaries of the N communities. In addition, N subgraphs corresponding to the first N entities can be obtained from the bottom knowledge graph in the double-layer knowledge graph, and a text description of the N subgraphs can be generated. On this basis, a global answer can be generated based on the input text, multiple intermediate input texts, and the text description of the N subgraphs. By combining the double-layer knowledge graph with RAG technology, utilizing the complex relationship query capabilities of the double-layer knowledge graph and the global perspective of the community summary, the deficiencies of traditional RAG technology in global query-focused question-answering in the field of intelligent question-answering can be made up, and the accuracy and comprehensiveness of intelligent question-answering of RAG technology can be improved.
[0109] The present application also provides an intelligent question-and-answer device, comprising: a processor, and a memory storing instructions, which, when executed by the processor, enable the processor to execute the above-mentioned intelligent question-and-answer method.
[0110] Figure 2 is a schematic diagram of the hardware structure of the intelligent question-answering device according to an embodiment of the present application. Figure 2 The intelligent question-answering device shown may include a processor 21 and a memory 22 storing computer program instructions.
[0111] Specifically, the processor 21 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.
[0112] The memory 22 may include a large capacity memory for data or instructions. Where appropriate, the memory 22 may include removable or non-removable (or fixed) media. In a particular embodiment, the memory 22 is a non-volatile solid-state memory. The memory 22 may include a read-only memory (ROM), a random access memory (RAM), a disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Therefore, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the above-mentioned intelligent question-answering method.
[0113] The processor 21 implements the intelligent question-answering method in the above embodiment by reading and executing computer program instructions stored in the memory 22 .
[0114] In one example, the intelligent question-answering device may further include a communication interface 23 and a bus 24. Figure 2 As shown, the processor 21, the memory 22, and the communication interface 23 are connected via a bus 24 and communicate with each other.
[0115] Bus 24 includes hardware, software or both, and the parts of intelligent question-answering device are coupled to each other. For example, but not limitation, bus can include accelerated graphics port (AGP) or other graphics bus, enhanced industrial standard architecture (EISA) bus, front-end bus (FSB), hypertransport (HT) interconnection, industrial standard architecture (ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 24 can include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.
[0116] The present application also provides a computer-readable storage medium on which instructions are stored. When the instructions are executed by a computer, the computer executes the above-mentioned intelligent question-answering method.
[0117] Examples of computer-readable storage media include non-transitory computer-readable storage media, such as portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk-read-only memory (CD-ROM), optical storage devices, magnetic storage devices, etc.
[0118] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.
[0119] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.
Claims
1. An intelligent question-answering method, comprising: Receive input text; Based on the input text, obtain the top N entities with the highest similarity from the vector knowledge base, where N is an integer greater than or equal to 1; Obtaining corresponding N communities from the top-level knowledge graph in the double-layer knowledge graph based on the first N entities; Based on the input text and the community summaries of the N communities, a plurality of intermediate input texts are generated by the intelligent question-answering large language model; Obtaining corresponding N subgraphs from the bottom layer knowledge graph in the double-layer knowledge graph based on the first N entities; Generating text descriptions of the N subgraphs by the intelligent question-answering large language model; Based on the input text, the multiple intermediate input texts, and the text descriptions of the N subgraphs, a global answer is generated by the intelligent question-answering large language model.
2. The intelligent question-answering method according to claim 1, wherein: The top N entities with the highest similarity obtained from the vector knowledge base based on the input text include: Performing vectorization processing on the input text to obtain vectorized input text; Similarity calculation is performed in the vector knowledge base according to the vectorized input text to obtain the top N entities with the highest similarity.
3. The intelligent question-answering method according to claim 1, wherein: Based on the input text and the community summaries of the N communities, the intelligent question-answering large language model generates multiple intermediate input texts, including: Based on the input text and the community summaries of the N communities, the intelligent question-answering large language model generates corresponding N intermediate answers and usefulness scores; Based on the usefulness score, first K intermediate answers among the N intermediate answers are obtained, and the first K intermediate answers are concatenated in descending order of usefulness scores and divided into the multiple intermediate input texts according to a fixed character string length.
4. The intelligent question-answering method according to claim 1, wherein: The text description of the N subgraphs generated by the intelligent question-answering large language model includes: The intelligent question-answering large language model generates text descriptions of the N subgraphs based on the entities and relationships in each subgraph.
5. The intelligent question-answering method according to claim 1, wherein: The two-layer knowledge graph is automatically created by the intelligent question-answering large language model using a first prompt template, wherein the first prompt template includes a task objective, execution steps, and context examples.
6. The intelligent question-answering method according to claim 5, wherein: The top-level knowledge graph is automatically created by the intelligent question-answering big language model using the first prompt template based on a user predefined data set, and wherein the bottom-level knowledge graph is automatically created by the intelligent question-answering big language model using the first prompt template based on a professional standard data set.
7. The intelligent question-answering method according to claim 1, wherein: The top-level knowledge graph includes entities, relationships and communities, the bottom-level knowledge graph includes entities and relationships, and Among them, the entities in the top-level knowledge graph are linked to the entities in the bottom-level knowledge graph by the intelligent question and answer large language model based on similarity calculation.
8. The intelligent question-answering method according to claim 7, wherein: The entity includes an entity name, an entity type and an entity description, the relationship includes a source entity, a target entity, a relationship description and a relationship weight, and the community is a collection of entities and relationships obtained by aggregating entities and relationships in the top-level knowledge graph based on a community clustering algorithm.
9. The intelligent question-answering method according to claim 1, wherein: The community summary of each community in the top-level knowledge graph is automatically created by the intelligent question-answering language model using a second prompt template, wherein the second prompt template includes a task objective and a community summary format.
10. The intelligent question-answering method according to claim 1, wherein: The vector knowledge base is created in the following way: The entities, relationships, and communities in the top-level knowledge graph are vectorized to obtain vectorized entities, vectorized relationships, and vectorized communities, and wherein the vector knowledge base includes the entities, the relationships, the communities, the vectorized entities, the vectorized relationships, and the vectorized communities.
11. An intelligent question-answering device, comprising: processor, and A memory storing instructions, wherein when the instructions are executed by the processor, the processor is caused to perform the method according to any one of claims 1 to 10.
12. A computer-readable storage medium having instructions stored thereon, wherein when the instructions are executed by a computer, the computer is caused to perform the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Large model multi-round dialogue method and device, computer equipment and storage medium
CN118036756A
Construction industry safety question and answer method and equipment based on large language model technology
CN118332092A
Response enhancement method and device based on RAG technology
CN119005330A
Domain intelligent question-answering system and method based on knowledge graph library and text vector library
CN119128095A
Dynamic natural language processing system for improved contextual understanding and interactive response
US20240411988A1
Cited By
Online customer service response method and device, equipment, storage medium and product
CN120687562A