Question and answer method, device, non-volatile storage medium and electronic device
By constructing independent first and second knowledge graphs, information is extracted from policy documents and business texts respectively and collaborative reasoning is performed, which solves the problem that a single knowledge graph cannot dynamically reflect user feedback and improves the accuracy and practicality of government Q&A.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-04
- Publication Date
- 2026-03-24
AI Technical Summary
A single knowledge graph cannot dynamically reflect user feedback, resulting in low accuracy of answers in government affairs Q&A.
By constructing and utilizing independent first and second knowledge graphs, information is extracted from policy documents and business texts of public service platforms to generate natural language text. Then, through collaborative reasoning using an intent recognition model, response content is generated.
It improves the accuracy of Q&A content and provides more practical responses by combining theoretical and practical information.
Smart Images

Figure CN121051253B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of language processing technology, and more specifically, to a question-and-answer method, apparatus, non-volatile storage medium, and electronic device. Background Technology
[0002] In the field of government affairs Q&A, relevant intelligent Q&A methods rely on a single knowledge graph to process user queries. This knowledge graph is constructed from official materials such as policy documents and service guides, aiming to provide authoritative and standardized information. However, the limitation of a single knowledge graph is that it cannot dynamically reflect and process feedback information from users' actual operations, especially when this feedback reveals discrepancies between policy provisions and actual implementation, making it unable to provide accurate and practical responses.
[0003] There is currently no effective solution to the above problems. Summary of the Invention
[0004] This application provides a question-answering method, apparatus, non-volatile storage medium, and electronic device to at least solve the technical problem of low accuracy of answers caused by the inability of a single knowledge graph to comprehensively retrieve query content.
[0005] According to one aspect of this application, a question-answering method is provided, comprising: receiving query content and determining a preset standard node to which the query entity in the query content belongs; determining subgraphs associated with the preset standard node in a first knowledge graph and a second knowledge graph respectively, to obtain a first subgraph and a second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other; converting the first subgraph and the second subgraph into natural language text respectively, to obtain a first text and a second text; generating target prompt words based on the query content, the first text, and the second text, and analyzing the target prompt words using an intent recognition model to obtain the answer content output by the intent recognition model.
[0006] Optionally, the first knowledge graph is constructed by the following method: obtaining policy documents; converting policy documents into policy text, identifying entities in the policy text, and obtaining multiple first entities; extracting knowledge representations corresponding to the first entities based on their context, and obtaining multiple first knowledge representations; converting different entity names used to refer to the same object into the same preset name in the first knowledge representations, and obtaining multiple target knowledge representations; storing the multiple target knowledge representations in a graph database, and obtaining the first knowledge graph.
[0007] Optionally, the second knowledge graph is constructed by the following method: obtaining business text from a public service platform; extracting target text fragments from the business text to represent the matters described by the target object, wherein the target text fragments include text content about the problems encountered by the target object in the public service; clustering the target text fragments with semantic similarity greater than a first preset threshold to obtain clustering results; associating the clustering results with the first entity in the first knowledge graph, and storing the association results in a graph database to obtain the second knowledge graph.
[0008] Optionally, subgraphs associated with preset standard nodes are determined in the first knowledge graph and the second knowledge graph, respectively, to obtain the first subgraph and the second subgraph, including: in the first knowledge graph, starting from the preset standard node, traversing the first knowledge graph until reaching a depth of i; collecting all first neighbor nodes visited during the traversal, and collecting the first edges connecting the preset standard node and all first neighbor nodes, as well as the first edges between the first neighbor nodes, where i is a positive integer; constructing the first subgraph based on the preset standard node, the first neighbor nodes, and the first edges; in the second knowledge graph, starting from the preset standard node, traversing the second knowledge graph until reaching a depth of j; collecting all second neighbor nodes visited during the traversal, and collecting the second edges connecting the preset standard node and all second neighbor nodes, as well as the second edges between the second neighbor nodes, where j is a positive integer; constructing the second subgraph based on the preset standard node, the second neighbor nodes, and the second edges.
[0009] Optionally, the first subgraph and the second subgraph are converted into natural language text to obtain the first text and the second text, respectively, including: converting the first subgraph into natural language text using a first predefined template to obtain the first text, wherein the title of the first text is related to the knowledge source of the first knowledge graph; and converting the second subgraph into natural language text using a second predefined template to obtain the second text, wherein the title of the second text is related to the knowledge source of the second knowledge graph.
[0010] Optionally, the method further includes: determining the conflict index of each node in the second knowledge graph based on the attribute information of each node in the second knowledge graph, wherein the attribute information includes at least the frequency of occurrence of the node in the second knowledge graph, and the conflict index is a numerical indicator used to indicate the degree of negative attention caused by the entity represented by the node in the domain covered by the second knowledge graph; identifying a first node in the second subgraph whose conflict index is greater than a second preset threshold; converting the first node and the edges between the first nodes into natural language text to obtain a third text; and generating prompt words based on the query content, the first text, and the third text.
[0011] Optionally, the attribute information may also include: negative sentiment score and / or node centrality index in the second knowledge graph, wherein the negative sentiment score is a quantitative measure of the negative emotional tendency expressed by the entity represented by the node in the context.
[0012] Optionally, the answer content includes at least one field name and the field value corresponding to the field name; after obtaining the answer content output by the intent recognition model, the method further includes: obtaining a user interface template, wherein the user interface template is used to define the layout of the content container and the identifier of the content container; matching the field name of the target field in the answer content with the identifier of the content container; and injecting the field value corresponding to the successfully matched field name into the matched content container to display the answer content in the user interface.
[0013] According to another aspect of this application, a question-answering device is also provided, comprising: a receiving module, configured to receive query content and determine the preset standard node to which the query entity in the query content belongs; a determining module, configured to determine the subgraphs associated with the preset standard nodes in a first knowledge graph and a second knowledge graph respectively, to obtain a first subgraph and a second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other; a conversion module, configured to convert the first subgraph and the second subgraph into natural language text respectively, to obtain a first text and a second text; and a generating module, configured to generate target prompt words based on the query content, the first text, and the second text, and analyze the target prompt words using an intent recognition model to obtain the answer content output by the intent recognition model.
[0014] According to another aspect of this application, a non-volatile storage medium is also provided, the storage medium including a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the above-mentioned question-and-answer method.
[0015] According to another aspect of this application, an electronic device is also provided, comprising: a memory and a processor, the processor being configured to run a program stored in the memory, wherein the program executes the above-described question-and-answer method during runtime.
[0016] According to another aspect of this application, a computer program is also provided, wherein the computer program, when executed by a processor, implements the above-described question-and-answer method.
[0017] According to another aspect of this application, a computer program product is also provided, comprising a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program that, when executed by a processor, implements the above-described question-and-answer method.
[0018] In this application, the following methods are employed: receiving query content and determining the preset standard node to which the query entity in the query content belongs; determining the subgraphs associated with the preset standard node in the first knowledge graph and the second knowledge graph respectively, resulting in a first subgraph and a second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other; converting the first subgraph and the second subgraph into natural language text respectively, resulting in a first text and a second text; generating target prompt words based on the query content, the first text, and the second text, and analyzing the target prompt words using an intent recognition model to obtain the answer content output by the intent recognition model. This method achieves the goal of comprehensively retrieving the query content, thereby improving the technical effect of the answer content and solving the technical problem of low accuracy of the answer content caused by the inability of a single knowledge graph to comprehensively retrieve the query content. Attached Figure Description
[0019] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0020] Figure 1 This is a flowchart of a question-and-answer method according to an embodiment of this application;
[0021] Figure 2 This is a logical architecture diagram of a question-answering system according to an embodiment of this application;
[0022] Figure 3 This is a structural diagram of a question-and-answer device according to an embodiment of this application;
[0023] Figure 4 This is a hardware structure block diagram of a computer terminal for a question-and-answer method according to an embodiment of this application. Detailed Implementation
[0024] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0025] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0026] According to an embodiment of this application, a method embodiment of a question-and-answer method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0027] Figure 1 This is a flowchart of a question-and-answer method according to an embodiment of this application, such as... Figure 1 As shown, the method includes the following steps:
[0028] Step S102: Receive the query content and determine the preset standard node to which the query entity in the query content belongs.
[0029] The preset standard nodes are nodes in the first knowledge graph and the second knowledge graph.
[0030] When a user asks a question, such as how to handle a certain government procedure, the received query is processed using natural language processing to identify key entities and intents. Key entities can be specific government matters, required materials, locations, times, etc. After identifying the query entities, they are categorized under predefined standard nodes. Standard nodes are predefined, standardized concepts representing various government matters and their attributes. For example, "replace ID card" is mapped to the standard node "ID card replacement process." Through standardization, even if users express their questions differently, it ensures that both the first and second knowledge graphs understand the same concept, laying the foundation for subsequent retrieval and reasoning.
[0031] Step S104: Determine the subgraphs associated with the preset standard nodes in the first knowledge graph and the second knowledge graph respectively to obtain the first subgraph and the second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other.
[0032] The first knowledge graph includes theoretical standard information, while the second knowledge graph includes practical reality information. Theoretical standard information refers to the rules, processes, standards, and requirements explicitly defined in normative guidance documents or policies issued by official or authoritative institutions. This information represents behavioral guidelines and expected outcomes under ideal conditions. Practical reality information refers to the real experiences, problems, obstacles, and additional requirements collected during actual operation or execution through user feedback, on-site observation, data analysis, etc. This information represents the application effects of theoretical standards in specific scenarios and potential deviations.
[0033] Optionally, the first knowledge graph includes at least policies and regulations, and the second knowledge graph includes at least the business texts of the public service platform. The content in the first knowledge graph forms the basis of the "ought-to-be" state of government affairs, that is, the theoretically required procedures and conditions that users should follow. For example, for the "ID card renewal" service, the first knowledge graph records in detail the normative information extracted from policy documents, such as each step, required materials, and processing time. The content in the second knowledge graph can be constructed based on public feedback data collected from channels such as the 12345 hotline and online services, aiming to reflect the "actual" state in the actual implementation of government affairs, such as common problems, special requirements, or obstacles. The first knowledge graph can be called a regulatory knowledge graph, and the second knowledge graph can be called a factual knowledge graph.
[0034] In step S104, based on the preset standard node determined in S102, targeted subgraph retrieval is performed in the parallel dual-track knowledge graph. All nodes and their edges directly or indirectly connected to the standard node are searched in both the first and second knowledge graphs. For example, for the standard node "ID card replacement process," all official regulations regarding the replacement process are retrieved from the first knowledge graph, while practical experience and feedback related to ID card replacement are searched in the second knowledge graph. The resulting first and second subgraphs will become important foundations for subsequent collaborative reasoning.
[0035] Step S106: Convert the first subgraph and the second subgraph into natural language text respectively to obtain the first text and the second text.
[0036] The purpose of step S106 is to enable the large language model to better understand and process this knowledge. Specifically, the first subgraph (a subgraph of the regulatory knowledge graph) is transformed into text that clearly lists all policy regulations and procedural steps. This text can begin with tags such as "official regulations" or "standard procedures" to ensure the authority and standardization of the information. Similarly, the second subgraph (a subgraph of the factual knowledge graph) is transformed into text describing the actual problems, special requirements, or common concerns encountered by the public when handling specific matters. This text can begin with tags such as "user feedback" or "first-hand experience" to emphasize its relevance and experiential nature. This transformation not only facilitates the understanding of the intent recognition model but also facilitates subsequent human-computer interaction.
[0037] Step S108: Based on the query content, the first text, and the second text, generate target prompt words, and use the intent recognition model to analyze the target prompt words to obtain the answer content output by the intent recognition model.
[0038] The intent recognition model includes large language models, which are not limited to specific models. In addition to GLM, Qwen, etc., it can also be any closed-source or open-source large model with strong logical reasoning capabilities, such as OpenAI's GPT series, Anthropic's Claude series, Meta's Llama series, etc.
[0039] Step S108 uses the user's original query, along with the transformed first and second texts mentioned above, as input to construct a complex target prompt (CoT Prompt). The target prompt guides the intent recognition model to compare and analyze information from different knowledge sources, enabling the model to not only summarize official regulations but also analyze differences in actual implementation and provide comprehensive suggestions based on this information. The intent recognition model performs in-depth analysis of the target prompt to understand the user's true needs and the context of the scenario. The intent recognition model outputs structured, multi-layered answer content, including, for example, a list of necessary materials (e.g., "Document Requirements"), special considerations for actual implementation (e.g., "Special Reminders"), and suggestions on how to smoothly complete the process (e.g., "Service Suggestions").
[0040] Optionally, the query content, the first text, and the second text can be dynamically embedded into a preset chained thinking prompt template to obtain the target prompt. The chained thinking prompt is a complex instruction text designed to stimulate large language models to perform step-by-step, explicit reasoning. It guides the model to simulate the thought process of human experts by setting a series of ordered sub-tasks, thereby improving its performance on complex logical reasoning tasks.
[0041] For example, the structure of a chain-thinking prompt template is as follows:
[0042] Chain-thinking prompt design:
[0043] You are an experienced government affairs expert. Please answer the user's question based on the following information.
[0044] # User Issues
[0045] {The original user question is embedded here, such as:}
[0046] How do I apply for a passport?
[0047] }
[0048] # Knowledge Base:
[0049] ## [Official Regulations]
[0050] {This section embeds the serialized regulatory knowledge text, such as:}
[0051] - Documents required for passport application: ID card
[0052] - Required documents for passport application: Photo
[0053] Passport application process steps: Online appointment
[0054] }
[0055] ## [Public Feedback]
[0056] {This section embeds serialized factual knowledge text, such as:}
[0057] - Passport application problem: Appointment system crashed
[0058] - Passport application issues: Photo returned due to strict requirements.
[0059] - Additional time spent processing passports: queuing for photos on-site.
[0060] }
[0061] # Task Instructions:
[0062] Please strictly follow these three steps to think through and generate your final response:
[0063] 1. Summarize the official path: Based on the official regulations, clearly and accurately describe the standard procedures and requirements.
[0064] 2. Analyze the differences in reality: Compare the official regulations and public feedback, identify and explain all key differences or potential obstacles in their actual implementation.
[0065] 3. Provide comprehensive suggestions: Based on the analysis in the previous two steps, generate a complete response that includes [Document Requirements], [Special Reminders], and [Service Suggestions].
[0066] On the other hand, in addition to using chain-like thinking prompt templates, for more complex conflict scenarios involving multiple intertwined factors, more advanced reasoning mechanisms can be employed, such as Tree of Thoughts (ToT). ToT allows the model to explore multiple different reasoning paths and evaluate and prune these paths, thereby finding the optimal explanation and solution in a broader space of reasoning.
[0067] It should be noted that steps S102 to S108 above are not limited to the field of government services. They can be extended to any field where there is a difference between "theoretical standards" and "practical reality," such as: 1. Internal compliance review of enterprises: constructing a "knowledge graph of company rules and regulations" and a "knowledge graph of employee actual behavior logs" to identify potential violations. 2. Legal consultation: constructing a "knowledge graph of legal provisions" and a "knowledge graph of past cases" to provide lawyers with theoretical and practical references when analyzing cases. 3. Medical auxiliary question answering: constructing a "knowledge graph of clinical treatment guidelines" and a "knowledge graph of patient-reported outcomes" to help doctors and patients understand the diverse effects and side effects of standardized treatment plans in the real world.
[0068] Based on the above steps, the system receives query content and determines the preset standard node to which the query entity belongs. It then identifies subgraphs associated with the preset standard node in both the first and second knowledge graphs, resulting in a first subgraph and a second subgraph, where the knowledge sources and embedding targets of the first and second knowledge graphs are independent. The first and second subgraphs are then converted into natural language text, resulting in a first text and a second text. Based on the query content, the first text, and the second text, target prompts are generated, and an intent recognition model is used to analyze these prompts to obtain the answer content output by the intent recognition model. This approach achieves the goal of comprehensively retrieving the query content, thereby improving the accuracy of the answer content.
[0069] Specifically, in the area of government affairs Q&A, existing systems are limited to providing theoretical answers derived from official policy documents. While these answers may be accurate in wording, their practical utility is greatly reduced when policies are outdated or incomplete, and they may not offer much guidance to users. This application, however, constructs and utilizes a factual knowledge graph, combined with a legal knowledge graph for conflict detection and collaborative reasoning. The generated responses not only contain authoritative information stipulated in documents but also incorporate warnings of obstacles in real-world scenarios. This significantly improves the practicality and accuracy of the responses, effectively extending the utility of theoretical knowledge to practical operations.
[0070] The following are Figure 1 The steps shown are illustrated and explained by way of example.
[0071] According to some optional embodiments of this application, the first knowledge graph is constructed by the following method: obtaining policy documents; converting policy documents into policy text, identifying entities in the policy text, and obtaining multiple first entities; extracting knowledge representations corresponding to the first entities based on the context of the first entities, and obtaining multiple first knowledge representations; converting different entity names used to refer to the same object into the same preset name in the first knowledge representations, and obtaining multiple target knowledge representations; storing the multiple target knowledge representations in a graph database to obtain the first knowledge graph.
[0072] In this embodiment, the latest policy documents are first obtained. These documents include detailed regulations on the conditions, procedures, and required materials for various government services. The policy documents are then converted into a unified policy text format to facilitate subsequent in-depth analysis using natural language processing technology.
[0073] Secondly, in the process of converting policy documents into policy text, text parsing and conversion technologies are used to format the documents, ensuring that all information is accurately converted into text strings. Specifically, non-text elements such as images and tables are removed from the documents, retaining only the plain text information, while maintaining the original paragraph structure and sentence integrity.
[0074] Then, a domain-fine-tuned named entity recognition model is used to comprehensively scan the transformed policy text and identify key entities. The named entity recognition model has been pre-trained on a large amount of text data in the government affairs domain, thus accurately identifying government-related entities (first entities) such as "business license," "ID card," and "residence permit." The first entities are the basic units for constructing the first knowledge graph.
[0075] Next, based on the context information of the entity, the knowledge representation corresponding to the entity is extracted. The knowledge representation can be in the form of a triple, with the triple structure being (subject, predefined relation, object). Triples can clearly and structurally express the relationship between entities. For example, "ID card" as an entity, its corresponding knowledge representation can be a triple connected to another entity "passport application" through the predefined relation "required materials": (passport application, required materials, ID card).
[0076] In government documents, the same entity may have multiple different names or spellings, such as "ID card" which may be written as "resident ID card" or "identity certificate". By unifying these different entity names used to refer to the same object into a preset standard name, the problems caused by naming diversity are eliminated, ensuring the consistency of entity names within the subsequently constructed first knowledge graph.
[0077] Finally, by storing the target knowledge representation as nodes and edges in a graph database, a complete legal knowledge graph can be established, where each node represents a government entity and each edge represents a relationship between entities, such as the relationship between "processing items" and "required materials".
[0078] Alternatively, entities in policy texts can be identified using the following methods.
[0079] The acquired policy documents are converted into text format and then cleaned to remove irrelevant formatting marks, whitespace characters, and non-critical information, ensuring the accuracy of subsequent entity identification.
[0080] Pre-trained language models within deep learning frameworks, such as BERT, RoBERTa, or DistilBERT, are used as the foundational models for named entity recognition. These models have been pre-trained on large-scale corpora and possess basic text understanding capabilities.
[0081] The basic NER model described above is then fine-tuned for the government affairs domain. This fine-tuning process can be based on a training dataset labeled with government entities. Each entity in the dataset is explicitly labeled with category information, such as "processing item," "required materials," and "time limit." Through supervised training on this dataset, the model can learn the specific features and types of entities in government documents.
[0082] The preprocessed policy text is input into a finely tuned NER model, which outputs a series of entities and their type information. In the model's output, each entity is labeled with its category in the government ontology; for example, "ID card" is labeled as an entity of the "required materials" category.
[0083] Alternatively, the knowledge representation corresponding to the first entity can be extracted using the following method.
[0084] Locate the specific position of the identified first entity within the policy text. Within the entity's context, look for relational trigger words—words or phrases that imply relationships between entities. For example, for the entity "passport application," the context contains words like "requires," "includes," and "related," which can indicate pre-existing relationships between this entity and other entities, such as "required materials" or "process steps."
[0085] Dependency parsing techniques are used to perform grammatical analysis on sentences containing entities to determine the dependency relationships between words. For example, in the sentence "Passport application requires original and photocopy of ID card", "requires" is the predicate, and the objects connected to it are "original ID card" and "photocopy".
[0086] Knowledge representations can be extracted using deep learning methods or rule-based template matching. For example, for the sentence structure "X needs Y," X and Y can be automatically identified, and their relationship can be preset as "required materials." Template matching and pattern recognition technologies are particularly suitable for repetitive or fixed-structure sentences in policy texts, enabling the rapid and accurate extraction of relationships between entities.
[0087] By utilizing a specially trained relation extraction model, the context of entities is further analyzed to identify more complex pre-defined relationships between them. For example, the model can identify that in the statement "Applying for a residence permit requires submitting a rental contract," the relationship between "applying for a residence permit" and "rental contract" is "required materials." After determining the relationships between entities, knowledge triples are constructed in the form of (subject, relation, object). For example, from "Applying for a residence permit requires submitting a rental contract," a triple (apply for residence permit, required materials, rental contract) can be constructed.
[0088] Furthermore, the second knowledge graph is constructed by the following method: obtaining business text from the public service platform; extracting target text fragments from the business text to represent the matters described by the target object, wherein the target text fragments include text content about the problems encountered by the target object in the public service; clustering the target text fragments with semantic similarity greater than a first preset threshold to obtain clustering results; associating the clustering results with the first entity in the first knowledge graph, and storing the association results in the graph database to obtain the second knowledge graph.
[0089] Specifically, business texts from public service platforms are automatically or periodically retrieved. These texts can include 12345 hotline work order records, online consultation service records, and discussion posts about government services on social media. The sources of these business texts are broad, not limited to formal documents, but also including various user feedback and interaction records.
[0090] By employing natural language processing techniques, such as text understanding models and keyword extraction algorithms, we can conduct in-depth analysis of business texts to filter out text fragments describing the problems encountered by users. For example, a hotline ticket might contain the sentence, "I applied for a residence permit according to the online process, but was told that I lack community proof." This is a typical target text fragment, clearly indicating the unexpected problem the user encountered in the specific service.
[0091] Semantic clustering technology is employed. By calculating the semantic similarity between different text fragments, target text fragments with a semantic similarity greater than a first preset threshold are automatically grouped into the same group. The first preset threshold is a pre-defined numerical value used to define whether two text fragments are similar enough to be considered to describe the same problem. For example, if the threshold is set to 0.85, then all text fragments describing something like "lack of community proof" will be clustered together, forming a clear set of problems.
[0092] The problem set is further linked to the first entity in the legal knowledge graph. This linking process leverages the text understanding and reasoning capabilities of deep learning models to identify specific connections between each problem set and government affairs or procedures. For example, the problem of "lacking community proof" might be associated with the first entity "residence permit application." This linking not only identifies which service or process causes the most user confusion but also pinpoints which official regulations differ from actual implementation, providing crucial clues for subsequent collaborative reasoning and the generation of explanatory answers.
[0093] Finally, the association results are stored in a graph database, forming a component of the factual knowledge graph. The graph database can efficiently store and query complex relationships between entities, enabling each user query to quickly retrieve relevant factual and legal knowledge for in-depth comparison and reasoning. It should be noted that the construction of the second knowledge graph essentially involves structuring information such as problem points, obstacle descriptions, and additional requirements from user feedback, and comparing them with the "ideal process" in the legal knowledge graph.
[0094] On the other hand, in addition to employing named entity recognition and relation extraction techniques, a second knowledge graph can also be constructed using link prediction algorithms in graph neural networks. By training on an existing factual knowledge graph, the link prediction algorithm can automatically predict and complete potential relationships that are not explicitly mentioned in user feedback but may logically exist, thereby further enriching and improving the second knowledge graph.
[0095] In some optional embodiments of this application, the subgraphs associated with the preset standard node are determined in the first knowledge graph and the second knowledge graph, respectively, to obtain the first subgraph and the second subgraph. This can be achieved by the following method: In the first knowledge graph, starting from the preset standard node, traversing the first knowledge graph until reaching a depth of i; collecting all first neighbor nodes visited during the traversal, and collecting the first edges connecting the preset standard node and all first neighbor nodes, as well as the first edges between the first neighbor nodes, where i is a positive integer; constructing the first subgraph based on the preset standard node, the first neighbor nodes, and the first edges; In the second knowledge graph, starting from the preset standard node, traversing the second knowledge graph until reaching a depth of j; collecting all second neighbor nodes visited during the traversal, and collecting the second edges connecting the preset standard node and all second neighbor nodes, as well as the second edges between the second neighbor nodes, where j is a positive integer; constructing the second subgraph based on the preset standard node, the second neighbor nodes, and the second edges.
[0096] In this embodiment, the preset standard nodes are determined based on the core entities in the user's question. For example, if a user asks about "applying for a residence permit," then the "apply for a residence permit" node becomes a preset standard node in both the first and second knowledge graphs. Starting from this node, a traversal of the knowledge graph begins using a breadth-first search strategy or a more complex graph search algorithm.
[0097] In the first knowledge graph, traversal begins with the preset standard node "Apply for Residence Permit" and expands along the edges of the graph until a specified layer depth of i is reached. During this process, all first neighbor nodes directly connected to the standard node are visited. These first neighbor nodes include entities such as "ID Card" and "Residence Certificate," which are connected to the standard node through preset relationships such as "Required Materials" or "Process Steps." Furthermore, the first edges connecting the standard node and its first neighbor nodes, as well as the edges between first neighbor nodes themselves, are collected; these edges represent direct or indirect relationships between entities. Based on the preset standard node, first neighbor nodes, and all first edges, a first subgraph focusing on the "Apply for Residence Permit" matter is constructed. This first subgraph reflects the official regulations and standard procedures required to complete this process.
[0098] Similarly, in the second knowledge graph, starting from the same preset standard node, a traversal is performed at a depth of j. The value of j may be different from or the same as i, depending on the structural complexity of the fact knowledge graph. Likewise, all directly related second neighbor nodes are visited, and the second edges connecting the preset standard node and the second neighbor nodes, as well as the edges between the second neighbor nodes, are collected. Second neighbor nodes include "community proof," "appointment system failure," etc. Based on the preset standard node, second neighbor nodes, and second edges, a second subgraph is constructed, reflecting the real problems and difficulties faced by users during actual service execution.
[0099] The first and second subgraphs represent the prescribed procedures under ideal specifications and the user experience in actual operation, respectively. A detailed comparison and analysis of the differences between the two subgraphs can identify potential conflicts between policy regulations and implementation reality. For example, if the requirement of "community verification" is absent in the first subgraph but frequently mentioned in the second, it indicates an inconsistency between actual practice and official regulations. This inconsistency is precisely the focus that this application needs to explore and explain in depth through collaborative reasoning mechanisms.
[0100] As some optional embodiments of this application, the first subgraph and the second subgraph are converted into natural language text to obtain the first text and the second text, respectively. This can be achieved by the following method: the first subgraph is converted into natural language text using a first predefined template to obtain the first text, wherein the title of the first text is related to the knowledge source of the first knowledge graph; the second subgraph is converted into natural language text using a second predefined template to obtain the second text, wherein the title of the second text is related to the knowledge source of the second knowledge graph.
[0101] Understandably, in order for large language models to understand and process the first and second subgraphs extracted from the dual-track knowledge graph, predefined templates are used to convert these subgraphs into natural language text.
[0102] For the first subgraph extracted from the regulatory knowledge graph, a first predefined template was used for transformation. This first predefined template is specifically designed to represent knowledge in its "ought" state, i.e., the ideal processes and regulations described in officially released policy documents, service guides, etc. The first predefined template contains transformation rules for preset standard nodes, first neighbor nodes, and first edges in the subgraph, ensuring that every entity and relationship can be accurately represented. For example, a typical transformation rule is as follows:
[0103] "According to the XX policy document, when processing the [Preset Standard Node], the following materials are required: [First Neighbor Node 1], [First Neighbor Node 2]... and the following steps must be completed: [First Neighbor Node 3], [First Neighbor Node 4]... Here, [First Neighbor Node 1] indicates that [First Neighbor Node 1] is a necessary material for the [Preset Standard Node], and [First Neighbor Node 2] indicates that [First Neighbor Node 2] is a step in the process."
[0104] By applying this template, the first subgraph can be structured and organized into a first text describing it in natural language. The title of the first text will clearly reflect its knowledge source, such as "Regulations of the XX Policy Document Regarding [Preset Standard Nodes]", to ensure that the large model can clearly distinguish the official nature of the knowledge when processing the text.
[0105] Similarly, the second subgraph extracted from the factual knowledge graph was transformed using a second predefined template. This second predefined template focuses more on describing knowledge in its "actual" state, i.e., the problems, obstacles, and informal additional requirements encountered by users in actual operation. The transformation rules also require accurate reflection of the entities and relationships in the subgraph, but their representation emphasizes the specific situations and details in actual operation. For example:
[0106] "Recently, citizens have reported the following issues when actually processing the [Preset Standard Node]: [Second Neighbor Node 1], [Second Neighbor Node 2]... It is worth noting that although not mentioned in official documents, according to user reports, the process of processing the [Preset Standard Node] may also involve [Second Neighbor Node 3]... Through [Second Neighbor Node 1], it was found that [Second Neighbor Node 1] is a common obstacle point for the [Preset Standard Node], while [Second Neighbor Node 2] illustrates the correlation between [Second Neighbor Node 2] and the [Preset Standard Node]."
[0107] Similarly, the second predefined template is applied to transform the second subgraph into the second text. The title of the second text will also be directly related to its knowledge source, such as "Practical problems and obstacles in citizen feedback regarding [preset standard nodes]", to ensure that the large model can accurately understand the practical experience knowledge contained in the second text during collaborative reasoning.
[0108] The first and second subgraphs not only retain all the details of the information in the subgraphs, but also clearly identify the official or unofficial sources of knowledge through clear titles, providing structured and clearly distinguishable natural language input for chain thinking and deep collaborative reasoning in large language models.
[0109] In some optional embodiments of this application, the above question-answering method further includes the following steps: determining the conflict index of each node in the second knowledge graph based on the attribute information of each node in the second knowledge graph, wherein the attribute information includes at least: the frequency of occurrence of the node in the second knowledge graph, and the conflict index is a numerical indicator used to indicate the degree of negative attention caused by the entity represented by the node in the domain covered by the second knowledge graph; determining the first node in the second subgraph whose conflict index is greater than a second preset threshold; converting the first node and the edges between the first nodes into natural language text to obtain the third text; and generating prompt words based on the query content, the first text, and the third text.
[0110] Optionally, the attribute information may also include: negative sentiment score and / or node centrality index in the second knowledge graph, wherein the negative sentiment score is a quantitative measure of the negative emotional tendency expressed by the entity represented by the node in the context.
[0111] It is worth explaining that, in order to more accurately identify and handle entities that frequently cause distress or dissatisfaction in practice, this embodiment introduces a conflict index calculation method based on a second knowledge graph (fact knowledge graph). The conflict index is a numerical indicator used to comprehensively assess the degree to which the entity represented by the node generates negative attention in the field of government services. The conflict index not only considers the frequency of the entity's appearance in the graph, but also further integrates negative sentiment scores and node centrality indicators to comprehensively measure the actual impact of the entity in real-world situations.
[0112] Frequency of occurrence serves as an intuitive quantitative indicator, reflecting how often an entity is mentioned in actual user feedback. If an entity (such as "additional community proof") appears frequently in the graph, especially in scenarios involving complaints or requests for help, it can be preliminarily determined that the entity carries a high degree of uncertainty or additional burden in the actual operation of government services, potentially becoming a hotspot for conflict.
[0113] Negative sentiment score provides a quantitative measure of emotional level. Based on sentiment analysis of user feedback text, it assesses the negative emotional tendency assigned to the entity represented by a node within a specific context. For example, if a user uses a large number of negative words or expresses strong dissatisfaction when mentioning "the appointment system crashed," then that entity will have a high negative sentiment score. Through negative sentiment score, insights can be gained into users' actual feelings and attitudes towards certain entities.
[0114] Centrality metrics for nodes, such as PageRank or Betweenness, reveal the relative importance of an entity within a knowledge graph. An entity will have a higher centrality metric if it lies on the connection paths of many other entities or has direct or indirect connections with a large number of other entities. Centrality metrics are used to identify entities that, while not directly appearing in users' immediate complaints, are the root cause of many other problems.
[0115] After determining the conflict index, a second preset threshold is set to filter out the first nodes whose conflict index significantly exceeds the average level. The first node represents the real problem or pain point in government services, causing significant inconvenience or distress to users in actual operation. The first node and the edges (i.e., relationships) between them are converted into natural language text, forming the third text. The third text details the specific content of the conflict point, the problems encountered by users, and the interactions between these entities.
[0116] During the generation of prompts, the query content, the first text (derived from the legal knowledge graph), and the third text (derived from the transformation of conflict nodes) are integrated to generate instructions that guide the large language model to perform in-depth analysis and logical reasoning. The prompts will clearly point out the differences between standard procedures and actual obstacles, and require the model to provide users with a multi-layered explanatory answer that conforms to official regulations while also considering practical problems, based on this information.
[0117] The above method can identify and quantify the discrepancies between "regulations" and "facts" in real time and automatically. Each identified high-frequency conflict point is a clear signal of a potential policy implementation deviation or a bottleneck in grassroots services. For example, when a large amount of factual data indicates that processing a certain business requires "supplementary materials" not mentioned in official documents, an alert is automatically generated.
[0118] As some alternative embodiments of this application, the answer content includes at least one field name and a field value corresponding to the field name; after obtaining the answer content output by the intent recognition model, the following steps can also be performed: obtaining a user interface template, wherein the user interface template is used to define the layout of the content container and the identifier of the content container; matching the field name of the target field in the answer content with the identifier of the content container; injecting the field value corresponding to the successfully matched field name into the matched content container to display the answer content in the user interface.
[0119] In this embodiment, after receiving the structured answer content output by the large model, this content is further parsed to identify the field names and their corresponding field values. A predefined user interface template is then loaded. This user interface template is specifically designed for government Q&A, defining the layout and style of each content container on the page, and assigning a unique identifier to each container. The identifier corresponds to the field names in the answer content, ensuring that the correct information is placed in the correct display position. For example, the template has a content container named "Document Requirements" to display a list of official documents required for handling specific matters; another content container named "Special Reminders" is used to display potential problems that users may encounter in actual operation and their solutions.
[0120] By matching the field names in the response content with the identifiers of the content containers in the user interface template, it can be ensured that the field value of each field is accurately placed in the corresponding display area. For example, the value of the "Document Requirements" field will be injected into a container with the same name, while the value of the "Special Reminder" field will be placed in the corresponding "Special Reminder" container.
[0121] The parsed and matched information is injected into the user interface, ensuring that the value of each field is displayed in the correct container, thus presenting a well-structured, information-rich, multi-layered answer interface on the screen. For example, the interface a user sees might first list the "Document Requirements," followed by a "Special Reminders" section explaining potential problems in practice, and "Suggestions" providing specific coping strategies and advice. This presentation method not only improves the readability and comprehension of the information but also greatly enhances the user experience, enabling users to quickly locate the information they need, understand official regulations, anticipate potential practical obstacles, and obtain practical advice on how to address these issues.
[0122] The aforementioned approach, by generating structured and interpretable multi-level answers, demonstrates a deep understanding of the policy context and empathy for users' real-world needs. When users find that the system's "special reminders" align with their problems, it not only proves the relevance of the system's responses but also enhances user confidence in the system. The question-and-answer system thus transcends merely repeating official text; it becomes like an experienced advisor, discerning the root causes of problems and providing solutions.
[0123] Figure 2 This is a logical architecture diagram of a question-answering system according to an embodiment of this application, such as... Figure 2 As shown, the system includes a regulatory knowledge graph construction module, a factual knowledge graph construction module, and an import collaborative reasoning module.
[0124] The regulatory knowledge graph construction module is used to perform the following steps.
[0125] Policy documents are uniformly converted into plain text that retains paragraph structure. Based on a predefined government ontology, a domain-adjusted Named Entity Recognition (NER) model is used to identify entities such as procedures and required materials in the text. Subsequently, a Large Language Model (LLM) is used to extract relationships between entities based on context, for example, extracting triples (apply for ID card, required materials, household registration book) from "apply for ID card". Entity links and disambiguation are performed on the extracted triples (e.g., unifying "ID card" and "resident ID card"), and then the standardized knowledge is stored in a graph database.
[0126] The fact knowledge graph construction module is used to perform the following steps.
[0127] Securely access text related to the 12345 hotline and automatically anonymize it, removing all personally identifiable information. Utilize LLM (Limited Language Management) to openly extract core obstacles from user feedback (e.g., "required to provide additional proof") from unstructured text. Then, use text embedding and clustering algorithms to aggregate semantically similar obstacles, and manually or through LLM, name the categories (e.g., "additional community proof") to dynamically expand the factual knowledge schema (database table structure design). Again, leverage LLM to associate the summarized factual obstacles with the procedures in the legal knowledge graph, attaching quantitative metadata such as frequency and timeliness to each factual knowledge triple, and finally storing it in a graph database.
[0128] Import the collaborative reasoning module to perform the following steps.
[0129] Query intent identification and entity linking. The system receives the user's original query (e.g., "My dad's passport has expired, how do I renew it?"). This query is input into an LLM (Learning Management System), which is instructed to perform two tasks: First, normalize the query intent to a predefined standard service type, such as identifying it as "passport renewal"; second, link the entities mentioned in the query to normalized nodes in the knowledge graph, such as linking "passport" to the corresponding material node. This step ensures the accuracy of subsequent retrievals.
[0130] K-hop subgraph extension retrieval based on a central node. Centered on a linked, normalized entity node (e.g., "passport renewal"), a k-hop neighbor retrieval algorithm (k is typically set to 1 or 2) is executed in both the regulatory knowledge graph and the factual knowledge graph. Starting from the central node, the algorithm traverses and collects all neighboring nodes within k depths around that node and the edges connecting them using methods such as breadth-first search (BFS). Ultimately, these two sets of retrieved nodes and edges constitute the regulatory subgraph and the factual subgraph, respectively, providing a precise and focused knowledge scope for subsequent reasoning.
[0131] Text serialization of knowledge subgraphs. The two subgraphs mentioned above are converted into natural language text that is easy for LLM to understand using predefined templates. For example, the regulatory subgraph is converted into a list-style text starting with "[Official Regulations]"; the fact subgraph is converted into text starting with "[Public Feedback]". This structured text input helps LLM better distinguish the source and nature of knowledge.
[0132] Dynamic chain-like thinking prompt construction. The user's original question and two serialized knowledge texts are dynamically embedded into a preset chain-like thinking prompt template.
[0133] Large language model inference and structured output. The completed prompt words are input into a large language model (such as GLM-4V). Simultaneously, the instruction model returns a structured output (such as JSON format) containing preset fields such as "[Document Requirements]", "[Special Reminders]", and "[Service Suggestions]". This approach ensures the stability and reliability of the model output, facilitating parsing and presentation to the user by the backend system.
[0134] Result formatting and presentation. After receiving the structured data returned by the LLM, the backend fills the content of different fields into the corresponding display areas (such as "File Requirements" and "Special Reminders" in the GUI interface) according to the preset front-end UI template, and finally presents the user with a clear, easy-to-understand, and information-rich multi-layered answer.
[0135] Figure 3 This is a structural diagram of a question-and-answer device according to an embodiment of this application, such as... Figure 3 As shown, the device includes:
[0136] The receiving module 32 is used to receive the query content and determine the preset standard node to which the query entity in the query content belongs.
[0137] The determination module 34 is used to determine the subgraphs associated with preset standard nodes in the first knowledge graph and the second knowledge graph respectively, to obtain the first subgraph and the second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other.
[0138] The conversion module 36 is used to convert the first subgraph and the second subgraph into natural language text respectively, to obtain the first text and the second text.
[0139] The generation module 38 is used to generate target prompt words based on the query content, the first text, and the second text, and to analyze the target prompt words using an intent recognition model to obtain the answer content output by the intent recognition model.
[0140] Optionally, the first knowledge graph is constructed by the following method: obtaining policy documents; converting policy documents into policy text, identifying entities in the policy text, and obtaining multiple first entities; extracting knowledge representations corresponding to the first entities based on their context, and obtaining multiple first knowledge representations; converting different entity names used to refer to the same object into the same preset name in the first knowledge representations, and obtaining multiple target knowledge representations; storing the multiple target knowledge representations in a graph database, and obtaining the first knowledge graph.
[0141] Optionally, the second knowledge graph is constructed by the following method: obtaining business text from a public service platform; extracting target text fragments from the business text to represent the matters described by the target object, wherein the target text fragments include text content about the problems encountered by the target object in the public service; clustering the target text fragments with semantic similarity greater than a first preset threshold to obtain clustering results; associating the clustering results with the first entity in the first knowledge graph, and storing the association results in a graph database to obtain the second knowledge graph.
[0142] Optionally, the determining module 34 is further configured to perform the following steps: In the first knowledge graph, starting from a preset standard node, traversing the first knowledge graph until reaching a depth of layer i; collecting all first neighbor nodes visited during the traversal, and collecting the first edges connecting the preset standard node and all first neighbor nodes, as well as the first edges between the first neighbor nodes, where i is a positive integer; constructing a first subgraph based on the preset standard node, the first neighbor nodes, and the first edges; In the second knowledge graph, starting from the preset standard node, traversing the second knowledge graph until reaching a depth of layer j; collecting all second neighbor nodes visited during the traversal, and collecting the second edges connecting the preset standard node and all second neighbor nodes, as well as the second edges between the second neighbor nodes, where j is a positive integer; constructing a second subgraph based on the preset standard node, the second neighbor nodes, and the second edges.
[0143] Optionally, the conversion module 36 is also configured to perform the following steps: converting the first subgraph into natural language text using a first predefined template to obtain a first text, wherein the title of the first text is related to the knowledge source of the first knowledge graph; and converting the second subgraph into natural language text using a second predefined template to obtain a second text, wherein the title of the second text is related to the knowledge source of the second knowledge graph.
[0144] Optionally, the question-answering device further includes a first generation module, configured to perform the following steps: determining the conflict index of each node in the second knowledge graph based on the attribute information of each node in the second knowledge graph, wherein the attribute information includes at least: the frequency of occurrence of the node in the second knowledge graph, and the conflict index is a numerical indicator used to indicate the degree of negative attention caused by the entity represented by the node in the domain covered by the second knowledge graph; identifying a first node in the second subgraph whose conflict index is greater than a second preset threshold; converting the first node and the edges between the first nodes into natural language text to obtain a third text; and generating prompt words based on the query content, the first text, and the third text.
[0145] Optionally, the attribute information may also include: negative sentiment score and / or node centrality index in the second knowledge graph, wherein the negative sentiment score is a quantitative measure of the negative emotional tendency expressed by the entity represented by the node in the context.
[0146] Optionally, the answer content includes at least one field name and the field value corresponding to the field name. The question-answering device is also configured to, after obtaining the answer content output by the intent recognition model, perform the following steps: obtain a user interface template, wherein the user interface template is used to define the layout of the content container and the identifier of the content container; match the field name of the target field in the answer content with the identifier of the content container; inject the field value corresponding to the successfully matched field name into the matched content container to display the answer content in the user interface.
[0147] It should be noted that the above Figure 3 The modules in can be program modules (e.g., a set of program instructions that implements a specific function) or hardware modules. For the latter, they can be represented in the following forms, but are not limited to these: each of the above modules is represented by a processor, or the functions of each of the above modules are implemented by a processor.
[0148] It should be noted that, Figure 3 Preferred embodiments of the shown examples can be found in [reference needed]. Figure 1 The relevant descriptions of the embodiments shown will not be repeated here.
[0149] Figure 4A hardware block diagram of a computer terminal for implementing a question-and-answer method is shown. Figure 4 As shown, the computer terminal 40 may include one or more processors 402 (shown as 402a, 402b, ..., 402n in the figure) 402 (processor 402 may include, but is not limited to, a microprocessor MCU or a programmable logic device FPGA, etc.), a memory 404 for storing data, and a transmission module 406 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of a BUS bus), a network interface, a power supply, and / or a camera. Those skilled in the art will understand that... Figure 4 The structure shown is for illustrative purposes only and does not limit the structure of the aforementioned electronic device. For example, computer terminal 40 may also include... Figure 4 The more or fewer components shown, or having the same Figure 4 The different configurations shown.
[0150] It should be noted that the aforementioned one or more processors 402 and / or other data processing circuits are generally referred to herein as "data processing circuits". These data processing circuits may be embodied, in whole or in part, in software, hardware, firmware, or any other combination thereof. Furthermore, the data processing circuits may be a single, independent processing module, or may be integrated, in whole or in part, into any other element within the computer terminal 40. As involved in the embodiments of this application, the data processing circuits serve as processor control (e.g., selection of a variable resistor termination path connected to an interface).
[0151] The memory 404 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the question-and-answer method in this embodiment. The processor 402 executes various functional applications and data processing by running the software programs and modules stored in the memory 404, thereby realizing the aforementioned question-and-answer method. The memory 404 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 404 may further include memory remotely located relative to the processor 402, and these remote memories can be connected to the computer terminal 40 via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0152] The transmission module 406 is used to receive or send data via a network. Specific examples of the network described above may include a wireless network provided by the communication provider of the computer terminal 40. In one example, the transmission module 406 includes a network interface controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission module 406 may be a radio frequency (RF) module, used for wireless communication with the Internet.
[0153] The display can be, for example, a touchscreen liquid crystal display (LCD) that allows the user to interact with the user interface of the computer terminal 40.
[0154] It should be noted here that, in some optional embodiments, the above... Figure 4 The computer terminal shown may include hardware components (including circuitry), software components (including computer code stored on a computer-readable medium), or a combination of both hardware and software components. It should be noted that... Figure 4 This is only one instance of a specific particular instance, and is intended to illustrate the types of components that may exist in the aforementioned computer terminal.
[0155] It should be noted that, Figure 4 The computer terminal shown is used to execute Figure 1 The question-and-answer method shown above means that the relevant explanations in the above command execution method also apply to this electronic device, and will not be repeated here.
[0156] This application also provides a non-volatile storage medium, which includes a stored program, wherein the program, when running, controls the device where the storage medium is located to execute the above question-and-answer method.
[0157] A non-volatile storage medium performs the following functions: receiving query content and determining the preset standard node to which the query entity in the query content belongs; determining the subgraphs associated with the preset standard node in the first knowledge graph and the second knowledge graph respectively, to obtain the first subgraph and the second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other; converting the first subgraph and the second subgraph into natural language text respectively, to obtain the first text and the second text; generating target prompt words based on the query content, the first text and the second text, and analyzing the target prompt words using an intent recognition model to obtain the answer content output by the intent recognition model.
[0158] This application also provides an electronic device, including a memory and a processor, wherein the processor is used to run a program stored in the memory, wherein the program executes the above-described question-and-answer method during runtime.
[0159] The processor is used to run a program that performs the following functions: receiving query content and determining the preset standard node to which the query entity in the query content belongs; determining the subgraphs associated with the preset standard nodes in the first knowledge graph and the second knowledge graph respectively, to obtain the first subgraph and the second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other; converting the first subgraph and the second subgraph into natural language text respectively, to obtain the first text and the second text; generating target prompt words based on the query content, the first text and the second text, and analyzing the target prompt words using an intent recognition model to obtain the answer content output by the intent recognition model.
[0160] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0161] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0162] In the above embodiments of this application, the information collected is information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data all comply with relevant laws, regulations and standards, take necessary protective measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.
[0163] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units can be a logical functional division, and in actual implementation, there may be other division methods. For instance, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling, direct coupling, or communication connection may be through some interfaces; the indirect coupling or communication connection between units or modules may be electrical or other forms.
[0164] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0165] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0166] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to related technologies, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, read-only memory (ROM), random access memory (RAM), portable hard drives, magnetic disks, or optical disks.
[0167] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A question and answer method, characterized by, include: Receive query content and determine the preset standard node to which the query entity in the query content belongs; Subgraphs associated with the preset standard nodes are determined in the first knowledge graph and the second knowledge graph respectively, resulting in the first subgraph and the second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other; The first subgraph and the second subgraph are converted into natural language text respectively to obtain the first text and the second text. Based on the query content, the first text, and the second text, target prompt words are generated, and the target prompt words are analyzed using an intent recognition model to obtain the answer content output by the intent recognition model.
2. The method of claim 1, wherein, The first knowledge graph was constructed using the following method: Obtain policy documents; The policy document is converted into policy text, and the entities in the policy text are identified to obtain multiple first entities; Based on the context of the first entity, extract the knowledge representation corresponding to the first entity to obtain multiple first knowledge representations; In the first knowledge representation, different entity names used to refer to the same object are converted into the same preset name to obtain multiple target knowledge representations; The multiple target knowledge representations are stored in a graph database to obtain the first knowledge graph.
3. The method of claim 2, wherein, The second knowledge graph was constructed using the following method: Obtain the business documents from the public service platform; Extract target text fragments from the business text to represent the matters described by the target object, wherein the target text fragments include text content about the problems encountered by the target object in public services; Clustering is performed on target text segments whose semantic similarity is greater than a first preset threshold to obtain clustering results; The clustering results are associated with the first entity in the first knowledge graph, and the association results are stored in the graph database to obtain the second knowledge graph.
4. The method of claim 1, wherein, Determine the subgraphs associated with the preset standard nodes in the first knowledge graph and the second knowledge graph respectively to obtain the first subgraph and the second subgraph, including: In the first knowledge graph, starting from the preset standard node, traversal is performed in the first knowledge graph until the depth of layer i is reached. Collect all first neighbor nodes visited during the traversal, and collect the first edges connecting the preset standard node and all first neighbor nodes, as well as the first edges between the first neighbor nodes, where i is a positive integer; Based on the preset standard node, the first neighbor node, and the first edge, construct the first subgraph; In the second knowledge graph, starting from the preset standard node, traversal is performed in the second knowledge graph until a depth of j is reached; Collect all second neighbor nodes visited during the traversal, and collect the second edges connecting the preset standard node and all second neighbor nodes, as well as the second edges between the second neighbor nodes, where j is a positive integer; The second subgraph is constructed based on the preset standard node, the second neighbor node, and the second edge.
5. The method according to claim 1, characterized in that, The first subgraph and the second subgraph are converted into natural language text respectively, resulting in the first text and the second text, including: The first subgraph is converted into natural language text using a first predefined template to obtain the first text, wherein the title of the first text is related to the knowledge source of the first knowledge graph. The second subgraph is transformed into natural language text using a second predefined template to obtain the second text, wherein the title of the second text is related to the knowledge source of the second knowledge graph.
6. The method according to claim 1, characterized in that, The method further includes: Based on the attribute information of each node in the second knowledge graph, the conflict index of each node in the second knowledge graph is determined, wherein the attribute information includes at least the frequency of occurrence of the node in the second knowledge graph, and the conflict index is a numerical indicator used to indicate the degree of negative attention caused by the entity represented by the node in the domain involved in the second knowledge graph. In the second sub-graph, a first node is identified whose conflict index is greater than a second preset threshold; The first node and the edges between the first nodes are converted into natural language text to obtain the third text. Based on the query content, the first text, and the third text, generate prompt words.
7. The method according to claim 6, characterized in that, The attribute information also includes: negative sentiment score and / or the centrality index of the node in the second knowledge graph, wherein the negative sentiment score is a quantitative measure of the negative emotional tendency expressed by the entity represented by the node in the context.
8. The method according to claim 1, characterized in that, The answer content includes at least one field name and the field value corresponding to the field name; After obtaining the response output by the intent recognition model, the method further includes: Obtain a user interface template, wherein the user interface template is used to define the layout of the content container and the identifier of the content container; Match the field name of the target field in the answer content with the identifier of the content container; The field values corresponding to the successfully matched field names are injected into the matching content container to display the answer content in the user interface.
9. A question-and-answer device, characterized in that, include: The receiving module is used to receive query content and determine the preset standard node to which the query entity in the query content belongs; The determination module is used to determine the subgraphs associated with the preset standard nodes in the first knowledge graph and the second knowledge graph, respectively, to obtain the first subgraph and the second subgraph, wherein the knowledge sources and embedding targets of the first knowledge graph and the second knowledge graph are independent of each other; The conversion module is used to convert the first sub-graph and the second sub-graph into natural language text respectively, to obtain the first text and the second text; The generation module is used to generate target prompt words based on the query content, the first text, and the second text, and to analyze the target prompt words using an intent recognition model to obtain the answer content output by the intent recognition model.
10. A non-volatile storage medium, characterized in that, The non-volatile storage medium includes a stored program, wherein, when the program is executed, it controls the device containing the non-volatile storage medium to perform the question-and-answer method according to any one of claims 1 to 8.
11. An electronic device, characterized in that, include: A memory and a processor, the processor being configured to run a program stored in the memory, wherein the program, when executed, performs the question-and-answer method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the question-and-answer method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Question and answer method for graph-driven fusion retrieval in field of computer networks
CN120336477A
Intelligent question-answering system optimization method and device based on knowledge graph
CN120804142A