A question and answer processing method, device, system and product
Patent Information
- Application Number
- CN202610807002.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-05
- Publication Date
- 2026-10-23
AI Technical Summary
[0004]然而,该种统一的处理方式在面对数值范围限定、极值寻优、属性值反向约束等逻辑复杂度高的查询任务时,往往难以有效表达并高效执行该类高阶计算,导致系统在处理复杂问句时表现不佳
[0009]根据本申请实施例的第四方面,提供了一种计算机程序产品,包括计算机程序指令,所述计算机程序指令在被处理器运行时使得所述处理器执行:如第一方面所述的问答处理方法。
Smart Images

Figure CN122964207A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the interdisciplinary field of natural language processing and knowledge engineering, and in particular to a question-answering processing method, device, system, and product. Background Technology
[0002] In question-answering systems that integrate knowledge graphs and large language models, the relevant technologies generally need to cope with diverse query requirements, ranging from regular structured queries to complex logic including numerical comparisons and extreme value judgments, in order to achieve accurate and efficient question-answering services.
[0003] To meet these requirements, a unified query processing mechanism is typically adopted. This involves using a single query engine to parse user questions and executing corresponding structured queries in the knowledge graph database. This approach usually transforms user questions of varying complexity into a single query processing flow, relying on pre-defined templates or semantic parsing models to directly map natural language into query statements for the knowledge graph database.
[0004] However, this unified approach often struggles to effectively express and efficiently execute high-order calculations when faced with query tasks that involve high logical complexity, such as numerical range constraints, extreme value optimization, and reverse constraint of attribute values, resulting in poor system performance when handling complex questions. Summary of the Invention
[0005] Based on the above-mentioned technological status, this application provides a question-answering processing method, device, system, and product that can improve the ability to handle complex reasoning problems.
[0006] To achieve the above-mentioned technical objectives, this application proposes the following technical solution: According to a first aspect of the embodiments of this application, a question-and-answer processing method is provided, comprising: determining a target query type corresponding to a user-input question; the target query type being a first query type or a second query type, wherein the query logic complexity of the second query type is higher than that of the first query type; routing the question to be processed to a query database corresponding to the target query type for information querying based on the target query type, thereby obtaining information query results in the query database corresponding to the target query type; the query database corresponding to the first query type being used for processing structured queries, and the query database corresponding to the second query type being used for processing logical reasoning queries, wherein the complexity of logical reasoning queries is higher than that of structured queries; and generating a response content for the question to be processed based on the information query results.
[0007] According to a second aspect of the embodiments of this application, an electronic device is provided, including a memory and a processor; the memory is connected to the processor and is used to store a program; the processor is used to implement the question-and-answer processing method as described in the first aspect by running the program in the memory.
[0008] According to a third aspect of the embodiments of this application, a question-answering system is provided, comprising: an input processing unit, an output processing unit, a first query database, and a second query database; the first query database is used to process structured queries, and the second query database is used to process logical reasoning queries, wherein the complexity of the logical reasoning queries is higher than that of the structured queries; the input processing unit is used to determine the target query type corresponding to a user-input question; the target query type is either a first query type or a second query type, wherein the query logic complexity of the second query type is higher than that of the first query type; based on the target query type, the question to be processed is routed to the query database corresponding to the target query type for information querying, thereby obtaining information query results under the query database corresponding to the target query type; wherein the first query type corresponds to the first query database, and the second query type corresponds to the second query database; the output processing unit is used to generate a response content for the question to be processed based on the information query results.
[0009] According to a fourth aspect of the embodiments of this application, a computer program product is provided, including computer program instructions that, when executed by a processor, cause the processor to perform: the question-and-answer processing method as described in the first aspect.
[0010] This application provides a question-answering processing method, device, system, and product. It parses user-input questions into either a first query type or a second query type with higher logical complexity, routes the question to a database for processing structured queries or a database for processing logical reasoning queries based on the determined query type, and generates corresponding response content based on the query results. This method leverages the advantages of each database to handle basic structured queries and complex logical reasoning queries respectively, thereby overcoming the limitations of a single query engine in complex tasks, effectively supporting high-order complex reasoning problems, and significantly improving the overall robustness and upper limit of reasoning ability of the question-answering system. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0012] Figure 1 This is a schematic diagram of the architecture of a question-and-answer processing system provided according to an embodiment of this application.
[0013] Figure 2 This is a flowchart of a question-and-answer processing method provided in an embodiment of this application.
[0014] Figure 3 A flowchart illustrating the specific implementation of step S201 provided in the embodiments of this application.
[0015] Figure 4 This is a flowchart of one implementation of step S301 provided in an embodiment of this application.
[0016] Figure 5 A flowchart illustrating another implementation of step S301 provided in an embodiment of this application.
[0017] Figure 6 A flowchart illustrating another implementation of step S301 provided in the embodiments of this application.
[0018] Figure 7 This is a schematic diagram of the structure of a problem-solving device provided in an embodiment of this application.
[0019] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0020] The technical solutions provided in this application can be applied, by way of example, to hardware devices such as processors, electronic devices, and servers (including cloud servers), or packaged as software programs and run. When the hardware device executes the processing procedure of the technical solutions in this application, or when the aforementioned software program is run, the target task can be automatically split and the application programming interfaces required by the task can be automatically invoked to achieve the purpose of the target task. This application only provides illustrative descriptions of the specific processing procedure of the technical solutions in this application and does not limit the specific implementation form of the technical solutions in this application. Any technical implementation form that can execute the processing procedure of the technical solutions in this application can be adopted by this application.
[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] Before introducing the solution proposed in this application, the relevant technologies will first be introduced: In the field of retrieval-enhanced question answering technology that integrates knowledge graphs and large language models, the commonly adopted technical approach to improve the factual accuracy and logical reasoning ability of answers is an architecture that integrates knowledge graph question answering with document-level retrieval enhancement generation. Specifically, this approach is implemented through a pipelined, modular processing: first, all entity, concept, and attribute data of the knowledge graph are loaded into memory; then, a semantic encoding model is used to vectorize the user question and graph elements respectively, and a candidate entity set is recalled through similarity calculation; next, candidate entities are injected as background knowledge into prompt words, and a large language model is used to align the user question with entities, identifying the entities, attributes, and concepts; then, based on the alignment results, the question intent is parsed into a structured query statement of the knowledge graph, and a traversal retrieval is performed in the knowledge graph database; finally, the retrieved structured knowledge is transformed into enhanced context, supplemented by a large language model to generate a natural language answer. This technical approach can alleviate the illusion of fact problem by using the structured knowledge of knowledge graphs to constrain the behavior of large language models. Furthermore, it can reduce the reliance of traditional knowledge graph question answering on manual rules by leveraging the semantic understanding capabilities of large language models, achieving better accuracy and flexibility in single-round, simple fact-based question answering scenarios.
[0023] However, this scheme employs a single structured query processing mechanism. To ensure efficient execution of routine entity attribute traversal queries, its inherent design can only cover graph traversal operations centered on entities or concepts. This means it is inherently unable to handle logical operations such as numerical range calculations, sorting optimization, and reverse screening based on text features. When faced with complex questions, it can only be downgraded to a simple query or fail directly. For example, in applications for popularizing paleontology knowledge, when users ask constrained questions with numerical thresholds, such as "What dinosaurs weighed more than 9 tons?", or questions involving extreme value sorting and multiple conditions, such as "What is the heaviest carnivorous dinosaur?", the relevant technology cannot map numerical comparison and extreme value optimization logic to graph traversal operations supported by the graph library. It can only return empty results or throw errors, leading to a significant increase in query failure rates.
[0024] In view of this, the embodiments of this application aim to provide a question-answering processing method, device, system, and product. This method improves the distribution decision-making stage and execution engine in the query processing flow by introducing a divide-and-conquer routing mechanism based on query complexity classification and a data architecture that configures differentiated storage and computation models for heterogeneous query databases. This effectively enhances the logical reasoning ability for numerical ranges, extreme value conditions, and multi-constraint composite queries without sacrificing the efficiency of conventional structured query traversal. These will be described in detail in the following embodiments.
[0025] Figure 1 This is a schematic diagram of the architecture of a question-and-answer processing system provided according to an embodiment of this application. Figure 1 As shown, the question-and-answer processing system includes: an input processing unit 100, an output processing unit 101, a first query database 102, and a second query database 103.
[0026] The input processing unit 100 is used to receive the user input of the problem to be processed, and determine the target query type corresponding to the problem to be processed. The target query type includes a first query type and a second query type with a query logic complexity higher than that of the first query type. Based on the target query type, the problem to be processed is routed to the query database corresponding to the target query type for information query, and the information query results under the query database corresponding to the target query type are obtained.
[0027] The first query database 102 is used to respond to information queries of the first query type and is configured to handle structured queries; the second query database 103 is used to respond to information queries of the second query type and is configured to handle complex logical reasoning queries.
[0028] The first query database 102 is configured as a knowledge graph database, which stores graph data such as entities, concepts, attributes, and relationships.
[0029] The second query database 103 is configured as an external search engine, such as Elasticsearch. The external search engine has a composite index structure that combines inverted indexes and dense vector indexes. Each data record corresponds to a single attribute of an entity, and the attribute record includes a numeric attribute range field.
[0030] The output processing unit 101 is connected to the first query database 102, the second query database 103, and the input processing unit 100, respectively, and is used to generate corresponding response content based on the information query results and the problem to be processed.
[0031] In some examples, input processing unit 100 and output processing unit 101 are deployed on the user's terminal device. First query database 102 and second query database 103 are deployed on a cloud server.
[0032] Exemplary methods Figure 2 This is a flowchart illustrating a question-and-answer processing method provided in an embodiment of this application. The method can be executed by an electronic device equipped with a processor, which runs a question-and-answer processing system. Figure 2 As shown, the question-and-answer processing method provided in this embodiment includes steps S201-S203: S201. Determine the target query type corresponding to the user-input question to be processed. The target query type is either the first query type or the second query type.
[0033] In this embodiment, users can input questions to be processed in natural language through a question-and-answer processing system deployed on their terminal devices.
[0034] The first query type typically corresponds to basic structured query tasks. The semantic structure of this type of query is relatively simple, and its solution can be achieved by traversing the knowledge graph in a finite number of steps. For example, querying a specific attribute value of a given entity, querying all entities contained under a certain concept category, or querying whether there is a direct relationship between two entities all belong to the first query type.
[0035] The second query type has a higher query logic complexity than the first query type. The second query type corresponds to complex logical reasoning query tasks. The semantic structure of this type of query typically implicitly involves operations such as numerical comparison, sorting, range filtering, or multi-condition combination judgment, making it impossible to obtain the final answer directly through simple graph traversal. For example, querying all entities whose weight is greater than a specific numerical threshold, querying entities with the largest or smallest value for a certain attribute, or determining entities that meet the conditions based on attribute features described in text all fall under the second query type. The query logic complexity involved in the second query type is reflected in its need to perform numerical calculations, sorting, or comprehensive judgments across conditions; its computational overhead and reasoning depth are both higher than those of the first query type.
[0036] S202. Based on the target query type, the problem to be processed is routed to the query database corresponding to the target query type for information query, and the information query results under the query database corresponding to the target query type are obtained.
[0037] In this embodiment, a corresponding query database is configured for each different type of query. The query database corresponding to the first query type is used to process structured queries. This database can be configured to process graph-based traversal queries, which can efficiently retrieve connection information of entities, attributes, and relationships in a network composed of nodes and edges.
[0038] The query database for the second query type is used to handle logical reasoning queries. This database is configured to handle operations such as numerical calculations, sorting, and text matching based on inverted indexes. Its internal data organization and computational operators are configured for complex queries. Because the complexity of logical reasoning queries in the second query type is higher than that of the first query type, the query database configured for the second query type needs to have stronger computational capabilities than the first query database.
[0039] The specific implementation of the routing operation may include: when the target query type is determined to be the first query type, the structured query expression corresponding to the problem to be processed (e.g., a graph query statement generated based on entity alignment results) is sent to the query database corresponding to the first query type, and the database performs graph traversal and returns a result set. When the target query type is determined to be the second query type, the complex query parameters corresponding to the problem to be processed (e.g., query conditions containing comparison operators and numerical thresholds) are sent to the query database corresponding to the second query type, and the database performs numerical range filtering, sorting, or mixed scoring sorting on the index structure and returns a result set that meets the conditions.
[0040] It should be noted that the accurate determination of the query type in step S201 is a prerequisite for the successful execution of the routing operation in step S202. If the determination of the query type is inaccurate, the query task may be incorrectly assigned to a database that is not adept at handling that type of task, leading to query failure or a sharp drop in performance. Therefore, this embodiment utilizes the collaborative processing of two different types of databases to efficiently handle basic structured queries and complex logical reasoning queries, leveraging the strengths of each database. This overcomes the limitations of a single query engine in handling complex tasks such as numerical range queries and extreme value queries, enabling effective handling of complex reasoning problems and improving the overall robustness and upper limit of the question-answering system's reasoning capabilities.
[0041] S203. Based on the information query results, generate the response content for the pending issues.
[0042] After obtaining the information query results, the information query results and the question to be processed can be input into the large language model. The model will then organize and generate the final response content in the form of natural language based on the factual information in the information query results.
[0043] Specifically, prompt word templates for question-and-answer processing can be generated based on the information query results and the questions to be processed, enabling the large language model to generate the response content for the questions to be processed based on the prompt word templates.
[0044] In some embodiments, to avoid the "fact illusion" problem inherent in large language models, strict instruction boundaries can be set in the prompt word template for question-and-answer processing, forcing the large language model to perform logical reasoning and summarization solely based on the information query results. Simultaneously, streaming technology is employed at the service interface layer to return the generated natural language answers to the client in real-time in the form of tokens, enhancing the user experience. In some examples, the prompt word template for this question-and-answer processing can be as follows: "You are a knowledge graph question-answering expert. You must answer strictly based on the provided background knowledge. Fabricating information out of thin air or making subjective assumptions about information not mentioned is strictly prohibited. Please follow the answering rules below:" 1. If the answer is based solely on background knowledge and no relevant matching content is found, output "No relevant information is currently available in the knowledge base"; 2. Answers must include matching background knowledge, along with brief reasoning or explanation. A small amount of relevant content is allowed, but irrelevant expansion is prohibited. 3. For multi-round Q&A sessions, answers should be based on a comprehensive understanding of the context of the previous round of questions and answers, as well as current background knowledge. 4. For conditional questions of the "yes / no" type, the facts should be stated first, followed by the conclusion, and the basis for reasoning should be clearly stated; 5. For questions involving comparison of multiple entities, specific comparison logic must be provided in conjunction with background knowledge; simply outputting the conclusion is insufficient.
[0045] [Standard Answer Example] Example 1 (without background knowledge): Question: How much did a Tyrannosaurus Rex weigh? Background information: None A: There is currently no relevant information in the knowledge base. Example 2 Question: Which dinosaurs belong to the suborder Sauropoda? Background information: {Concept name: "Sauropoda", Entity names: ["Argentinosaurus", "Diplodocus", "Mamenchisaurus"]} A: Dinosaurs belonging to the suborder Sauropoda include: Argentinosaurus, Diplodocus, and Mamenchisaurus.
[0046] Example 3 Question: What was the weight of the Lufengosaurus schlegelii? Background information: {Entity name: "Lufengosaurus of Xu's", Weight: "approximately 1 ton"} A: The weight of the Lufengosaurus schlegelii is approximately 1 ton.
[0047] Example 4 Question: Which was heavier, Tyrannosaurus Rex or Triceratops? Background information: {Entity name: "Tyrannosaurus Rex", weight: "6~10 tons"}; {Entity name: "Triceratops", weight: "6.1~12 tons"} A: Tyrannosaurus Rex weighed 6-10 tons, while Triceratops weighed 6.1-12 tons, therefore Triceratops was heavier.
[0048] Example 5 Question: Was Tyrannosaurus Rex over 2 meters long? Background information: {Entity name: "Tyrannosaurus Rex", length: "10~13 meters"} A: Yes, Tyrannosaurus Rex was 10-13 meters long, more than 2 meters.
[0049] Example 6 Previous question: What were the living habits of Maiasaura? A: Maiasaura lived in groups and cared for their young.
[0050] This round of questions: Is it carnivorous? Background information: {Entity name: "Maiasaura", Diet: "Herbivorous"} A: No, Maiasaura was herbivorous.
[0051] Example 7 Question: Which dinosaurs lived during the Late Cretaceous period? Background information: {Entity name: "Tyrannosaurus Rex", Era: "Late Cretaceous"}; {Entity name: "Triceratops", Era: "Late Cretaceous"} A: Dinosaurs that lived in the Late Cretaceous period included Tyrannosaurus Rex and Triceratops.
[0052] Now, please analyze based on the above requirements and examples: Previous question: {} answer:{} This round's question: {} Background information: {} answer:" The specific implementation methods of steps S201 and S202 above will be described below: Figure 3 A flowchart illustrating the specific implementation of step S201 provided in the embodiments of this application. For example... Figure 3 As shown, step S201, in determining the target query type corresponding to the problem to be processed, may further include the following steps S301 and S302: S301. Perform entity alignment on the problem to be processed to obtain the entity alignment result.
[0053] In real-world question-answering scenarios, question-answering systems cannot directly process questions expressed by users in natural language. Therefore, when determining the target query type corresponding to the question, entity alignment is required to map the expression in natural language to specific elements in the knowledge graph, thus obtaining the entity alignment result.
[0054] Step S301, which aligns entities to obtain the corresponding entity alignment result for the problem to be processed, can be implemented in several ways, as follows: In some implementations, when performing entity alignment on the problem to be processed and obtaining the corresponding entity alignment result, this embodiment can perform entity alignment on the problem to be processed based on the candidate schema set to obtain the entity alignment result. The mechanism is described in detail below with reference to the accompanying drawings: Figure 4 This is a flowchart illustrating one implementation of step S301 provided in an embodiment of this application. Figure 4 As shown, in this implementation, entity alignment is performed on the problem to be processed to obtain the entity alignment result, which may further include the following steps S401-S402: S401. Obtain a candidate schema set; the candidate schema set includes skeleton elements pre-loaded into the knowledge graph database in memory, and candidate entities related to the problem to be processed selected from an external search engine.
[0055] The skeleton elements include the concepts, attributes, and relationships of each entity in the knowledge graph database; the external search engine includes each entity in the knowledge graph database.
[0056] In this embodiment, the candidate schema set is a set of candidate elements for alignment algorithms or model references, including entities, concepts, attributes, and relationships. In related technologies, the entire knowledge graph is typically loaded into the memory of the terminal device to obtain the candidate schema set. This method severely impacts system memory usage and response performance. This embodiment pre-loads the skeleton elements from the knowledge graph database into the memory of the terminal device during the startup phase. Since the number of concepts, attributes, and relationships in a knowledge graph is typically much smaller than the number of entities (e.g., only a few hundred or a few thousand), this resident memory strategy allows this data to be quickly retrieved by subsequent processing steps without needing to be retrieved from the knowledge graph database each time. This eliminates the real-time retrieval overhead of this data while ensuring the integrity of the graph schema information.
[0057] For the massive and continuously growing entity data, this embodiment adopts an on-demand dynamic recall approach for candidate entities. Specifically, when filtering candidate entities from external search engines to construct a candidate schema set, to improve the matching accuracy and coverage of the recall, this embodiment can employ a scoring and filtering method that integrates text matching and vector semantics, specifically including the following steps a1-a4: Step a1: Filter out entities from external search engines whose attribute name field values are preset content and whose text matching score between the attribute value and the question to be processed is greater than a preset threshold.
[0058] The data storage structure of the external search engine can be shown in the table below: Table 1. Data storage structure of external search engines As shown in Table 1, the attribute records of an external search engine can include an attribute name field (property), an attribute value field (value), and a vectorized representation field (embeddings) of the corresponding attribute value. Based on this, the above filtering process can first perform a text matching preliminary screening, that is: filtering entity data from the external search engine whose attribute name field values are preset content and whose attribute value fields have text matching with the question to be processed. The preset content is usually attribute names that may directly contain entity references, such as "name" or "alias".
[0059] Step a2: Determine the semantic similarity score between the initially screened entities and the problem to be processed based on the vectorized representation of the initially screened entities and the problem to be processed.
[0060] In this step, both the problem to be processed and the initially screened entity records need to be vectorized using a semantic encoding model, and their semantic similarity scores are calculated. For example, the cosine similarity between the vectorized representation of the problem to be processed and the vectors stored in the embeddings field of the initially screened entities is calculated. This semantic similarity score reflects the degree of deep semantic matching between the initially screened entities and the problem to be processed.
[0061] Step a3: Based on the weighted fusion of text matching score and semantic similarity score, obtain the comprehensive matching score between the initially screened entities and the problem to be processed.
[0062] In this step, the text matching score and semantic similarity score are weighted and fused to obtain a comprehensive matching score between each initially screened entity and the question to be processed. The specific weighted fusion method can be implemented using Elasticsearch's `function_score` feature.
[0063] Step a4: Select the N entities with the highest comprehensive matching scores as candidate entities; N is a positive integer.
[0064] After obtaining the overall matching score, the sum of the matching scores of each preliminary screening entity is sorted in descending order, and the N preliminary screening entities with the highest overall matching scores are selected as the final recalled candidate entities.
[0065] This hybrid recall strategy, on the one hand, precisely identifies entities with related names through text matching, and on the other hand, captures related entities with similar semantics but different expressions through vector semantic retrieval. The weighted fusion of the two can effectively balance the accuracy and generalization of the recall, and can significantly improve the completeness and accuracy of the candidate entity set while controlling the size of the candidate entities fed into the large language model.
[0066] After obtaining candidate entities through steps a1-a4 above, the resident concept set, attribute set, and relation set in memory can be combined with the candidate entities dynamically retrieved from the external search engine to obtain a candidate schema set. This candidate schema set is used to provide a reference for subsequent entity alignment steps.
[0067] S402. Perform entity alignment on the problem to be processed based on the candidate schema set to obtain the entity alignment result.
[0068] Specifically, step S402 includes: generating entity alignment prompt word templates based on the candidate schema set; performing entity alignment on the problem to be processed using a large language model based on the prompt word templates to obtain the original alignment result, and converting the original alignment result into a structured alignment result based on a preset shortcode specification; and determining the final entity alignment result based on the structured alignment result.
[0069] After obtaining the candidate schema set, entity alignment can be performed on the problem to be processed. For example, the candidate schema set and the problem to be processed can be assembled into a prompt word template for entity alignment and input into the large language model. The large language model aligns colloquial expressions, vague descriptions, or expressions containing misspellings or missing words in the problem to the correct graph elements by referring to the standard names in the candidate schema set, generating the original alignment result.
[0070] In some examples, the entity-aligned cue word template can be as follows: "As a knowledge graph entity alignment expert, please perform accurate semantic alignment of user input by combining candidate schema elements and historical dialogue information. Strictly adhere to the following rules, output only the alignment result, and output "No answer" if alignment is not possible, without adding any additional explanation."
[0071] I. Core Alignment Rules 1. Matching is performed based on candidate concepts, attributes, and entities, and semantic correction and alignment are performed for cases with missing characters, misspelled characters, disordered characters, and extra characters; 2. If multiple elements are matched, all of them must be output without omission; 3. Multi-turn dialogues require combining historical input with referential entities to complete referential resolution and entity completion; 4. When multiple entities correspond to the same attribute, the attribute must be matched for each entity separately and the result output in full; 5. Explanation of logical symbols: "&" means AND, "|" means OR, and ";" means the order of reasoning.
[0072] II. Output Format Requirements 1. Identifier definitions: Concept C, Entity E, Attribute P, Attribute value V; Comparison operators: Greater than gt, Less than lt, Equal to eq; 2. Use eq only when the attribute value V appears; do not use eq only for entities / concepts / attributes. 3. Strictly adhere to the output format and do not include any extra content.
[0073] III. Candidate Schema Elements Candidate concept: {} Candidate attributes: {} Candidate entity: {} IV. Historical Input {} User input: {} Alignment result:” This entity alignment prompt template includes input areas such as task instructions, schema constraints, dynamic few-shot example guidance, multi-turn dialogue disambiguation, and user input. This structure aims to guide large language models to stably complete accurate entity alignment for referential resolution and semantic correction even in noisy scenarios with missing characters, misspellings, and aliases. The original alignment results are typically lengthy natural language alignment descriptions. To avoid the large language model directly outputting lengthy natural language alignment descriptions, leading to excessively long tokens in the output sequence and increasing inference latency, this embodiment employs an output compression method based on structured shortcode specifications to compress the output length and reduce response latency.
[0074] This shortcode specification contains a set of rules for converting aligned natural language descriptions into high-density structured strings. For example, the specification may include: Unified label abbreviations: "Attribute" or "Relationship" will be uniformly abbreviated as "P", "Entity" as "E", "Concept" as "C", and "Attribute Value" as "V".
[0075] Topological conjunction simplification: Connect entities, attributes, and concepts using the symbol "-".
[0076] Comparison operator abbreviation: The terms "greater than", "less than", and "equal to" in attribute value comparisons are represented by "gt", "lt", and "eq", respectively.
[0077] Logical symbol abbreviation: The "&" and "|" symbols in logical relations are used to represent "AND" and "OR" respectively.
[0078] For example, for the question "What is the largest carnivorous dinosaur discovered in terms of weight?", if described in natural language, the output might be "(attribute-equals-weight) and (attribute value-equals-maximum); (attribute-equals-diet) and (attribute value-equals-carnivorous); (concept-equals-dinosaur)". After compression using the above abbreviation specification, the result is converted to "(P-weight)&(V-eq-maximum); (P-diet)&(V-eq-carnivorous); (C-dinosaur)".
[0079] By using the aforementioned shortcode specification, large language models can transform their lengthy natural language descriptions into highly compressed combinations of shortcode tags and logical symbols, outputting simplified, structured alignment results. This significantly reduces the token length of the model-generated sequence while fully preserving entities, attributes, concepts, and their logical relationships. This reduces the decoding time overhead of the large language model during entity alignment and substantially lowers end-to-end system response latency.
[0080] Subsequently, this embodiment can also determine the final entity alignment result based on the structured alignment result. This process specifically includes: determining the structured alignment result as the final entity alignment result, or calibrating the structured alignment result to obtain the final entity alignment result.
[0081] Specifically, calibration operations can include concept-entity confusion correction and / or name standardization correction. In concept-entity confusion correction, entities and concepts in the alignment results are cross-validated with the actual entity and concept sets in the knowledge graph, automatically correcting potential entity (E) and concept (C) label confusion. For example, the large language model might mislabel the concept "dinosaur" as entity E; the calibration process will correct it to concept C. In name standardization correction, the edit distance between entity, concept, or attribute names in the structured alignment results and standard names in the knowledge graph is calculated. Names with edit distances less than or equal to a preset threshold (e.g., 2) are automatically corrected to standard names. Invalid elements that cannot be matched in the standard name library are removed, resulting in calibrated entity alignment results. This standardizes and validates the entity, concept, attribute, and relation names output by the large language model.
[0082] In other implementations, when performing entity alignment on the problem to be processed and obtaining the corresponding entity alignment result, this embodiment can also combine sample examples and candidate schema sets to jointly perform entity alignment on the problem to be processed, thereby obtaining the entity alignment result. The mechanism is described in detail below with reference to the accompanying drawings: Figure 5 A flowchart illustrating another implementation of step S301 provided in an embodiment of this application. For example... Figure 5 As shown, in this implementation, entity alignment is performed on the problem to be processed to obtain the entity alignment result, which may further include the following steps S501 and S502: S501. Select the M target sample examples with the highest similarity to the problem to be processed from the preset sample example library.
[0083] Specifically, step S501 further includes: calculating the similarity between each sample question and the question to be processed; and determining the M sample questions with the highest similarity and their corresponding entity alignment results as the M target sample examples. Here, M is a positive integer.
[0084] This embodiment requires the pre-construction of a sample example library. This library includes various sample questions and their corresponding entity alignment results. For example, it stores several standard structured examples, each of which can contain a sample question and its corresponding correct entity alignment result. When a user inputs a question to be processed, the library can be used to select the M target sample examples with the highest similarity to the current question.
[0085] In some examples, the examples in the sample example library may be as follows: For example, the question is: I want to learn about vertebrates. The corresponding entity alignment result is: (C-vertebrates).
[0086] Question: Please introduce Barkolomew Jiang and Maiasaura. The corresponding entity alignment results are: (E-Barkolomew Jiang) & (E-Maiasaura).
[0087] Question: What animals did Stegosaurus or Tyrannosaurus Rex prey on? Corresponding entity alignment result: (E-Stegosaurus)&(P-Predator Relationship)|(E-Tyrannosaurus Rex)&(P-Predator Relationship).
[0088] Question: What are some examples of herbivorous dinosaurs? Corresponding entity alignment results: (P-dietary)&(V-eq-herbivorous)&(C-dinosaur).
[0089] Question: What is the largest carnivorous dinosaur discovered in terms of weight? Corresponding entity alignment results: (P-weight)&(V-eq-largest); (P-diet)&(V-eq-carnivorous); (C-dinosaur).
[0090] Question: What are some terrestrial animals that are over 2.2 meters long or weigh over 10 kilograms? Corresponding entity alignment result: (P-body length)&(V-gt-2.2 meters)|(P-weight)&(V-eq-10 kilograms);(C-terrestrial animal).
[0091] The selection process in the sample example library may include: calculating the semantic similarity between each sample question in the sample example library and the current question to be processed. For example, a semantic encoding model (such as the BGE model) can be used to pre-vectorize each sample question and the question to be processed, and then the cosine similarity between the current question vector and the vectors of each sample question can be calculated. The higher the cosine similarity score, the closer the semantics. After sorting the samples in descending order of similarity score, the top M sample questions and their corresponding entity alignment results are selected as target sample examples.
[0092] S502. Based on the M target sample examples and the candidate schema set, perform entity alignment on the problem to be processed to obtain the entity alignment result.
[0093] Specifically, step S502 includes: generating entity alignment prompt word templates based on M target sample examples and a candidate schema set; performing entity alignment on the problem to be processed using a large language model based on the prompt word templates to obtain the original alignment result, and converting the original alignment result into a structured alignment result based on a preset shortcode specification; and determining the final entity alignment result based on the structured alignment result.
[0094] After obtaining M target sample examples and a candidate schema set, entity alignment can be performed on the problem to be processed based on these two pieces of information. For example, the M target sample examples, the candidate schema set, and the problem to be processed can be assembled into a prompt word template for entity alignment and input into a large language model. Guided by these highly relevant examples, the large language model can more accurately understand the alignment paradigm of the current task and, referring to the standard names in the candidate schema set, align colloquial expressions, vague descriptions, or expressions containing misspellings or missing words in the problem to the correct graph elements, generating the original alignment result.
[0095] In some examples, the entity-aligned cue word template can be as follows: "As a knowledge graph entity alignment expert, please perform accurate semantic alignment of user input by combining candidate schema elements and historical dialogue information. Strictly adhere to the following rules, output only the alignment result, and output "No answer" if alignment is not possible, without adding any additional explanation."
[0096] I. Core Alignment Rules 1. Matching is performed based on candidate concepts, attributes, and entities, and semantic correction and alignment are performed for cases with missing characters, misspelled characters, disordered characters, and extra characters; 2. If multiple elements are matched, all of them must be output without omission; 3. Multi-turn dialogues need to combine historical input with the referent entities to complete the referent resolution and entity completion; 4. When multiple entities correspond to the same attribute, the attribute must be matched for each entity separately and the result output in full; 5. Explanation of logical symbols: "&" means AND, "|" means OR, and ";" indicates the order of logical progression.
[0097] II. Output Format Requirements 1. Identifier definitions: Concept C, Entity E, Attribute P, Attribute value V; Comparison operators: Greater than gt, Less than lt, Equal to eq; 2. Use eq only when the attribute value V appears; do not use eq only for entities / concepts / attributes. 3. Strictly adhere to the output format and do not include any extra content.
[0098] III. Alignment Examples {} IV. Candidate Schema Elements Candidate concept: {} Candidate attributes: {} Candidate entity: {} V. Historical Input {} User input: {} Alignment result:” The original alignment result is usually a lengthy natural language alignment description. To avoid large language models directly outputting lengthy natural language alignment descriptions, which would result in excessively long tokens in the output sequence and significantly increase inference latency, this embodiment employs an output compression method based on structured shortcode specifications to compress the output length and reduce response latency.
[0099] This abbreviation specification contains a set of rules for converting natural language aligned descriptions into high-density structured strings. For example, the specification may include: uniformly abbreviating "attribute" or "relation" as "P", "entity" as "E", "concept" as "C", and "attribute value" as "V"; using the symbol "-" to connect entities, attributes, and concepts; using "gt", "lt", and "eq" respectively to represent "greater than", "less than", and "equal to" in attribute value comparisons; and using "&" and "|" respectively to represent "and" and "or" in logical relations.
[0100] For example, for the question "What is the largest carnivorous dinosaur discovered in terms of weight?", if described in natural language, the output might be "(attribute-equals-weight) and (attribute value-equals-maximum); (attribute-equals-diet) and (attribute value-equals-carnivorous); (concept-equals-dinosaur)". After compression using the above abbreviation specification, the result is converted to "(P-weight)&(V-eq-maximum); (P-diet)&(V-eq-carnivorous); (C-dinosaur)".
[0101] Using the aforementioned simplified code specification, the large language model can output a simplified structured alignment result, and determine the final entity alignment result based on this structured alignment result. This process specifically includes: determining the structured alignment result as the final entity alignment result, or calibrating the structured alignment result to obtain the final entity alignment result.
[0102] By using the aforementioned shortcode specification, large language models can transform their lengthy natural language descriptions into highly compressed combinations of shortcode tags and logical symbols, outputting simplified, structured alignment results. This significantly reduces the token length of the model-generated sequence while fully preserving entities, attributes, concepts, and their logical relationships. This reduces the decoding time overhead of the large language model during entity alignment and substantially lowers end-to-end system response latency.
[0103] Subsequently, this embodiment can also determine the final entity alignment result based on the structured alignment result. This process specifically includes: determining the structured alignment result as the final entity alignment result, or calibrating the structured alignment result to obtain the final entity alignment result.
[0104] The calibration process can include concept-entity confusion correction and / or name standardization correction. In concept-entity confusion correction, the entity labels in the structured alignment results are cross-validated with the actual entity and concept sets in the graph, automatically correcting potential label confusion issues. For example, the large language model might mislabel the concept "dinosaur" as entity E; the calibration process will correct it to concept C. In name standardization correction, the edit distance between the entity, concept, or attribute names in the structured alignment results and the standard names in the graph is calculated. Names with an edit distance less than or equal to a preset threshold (e.g., 2) are automatically corrected to standard names, while invalid elements that cannot be matched in the standard name library are removed, thus obtaining the calibrated entity alignment result.
[0105] This embodiment employs a dynamic few-sample example selection strategy, injecting only the top M examples highly semantically relevant to the current problem. This provides precise task guidance and a reference paradigm for the large language model, effectively overcoming the conceptual confusion and matching errors that easily arise from the lack of guidance in zero-sample alignment, thereby further improving the accuracy of entity alignment. Simultaneously, it avoids statically injecting a large number of irrelevant examples, significantly reducing the length of prompt words input to the large language model, lowering computational latency, and ultimately achieving a dual improvement in alignment accuracy and processing efficiency.
[0106] In multi-turn dialogues within a private computing power scenario, subsequent user questions often contain pronouns (such as "it," "they," "the latter") or omit the entity subject. Large language models are highly susceptible to focus drift and referential errors in addressing this issue, making it difficult to directly determine the specific entity referred to in the question and thus hindering entity alignment. To support accurate semantic understanding in multi-turn dialogues, this embodiment includes disambiguation processing for referential errors during entity alignment. The implementation process of this disambiguation processing is described in detail below with reference to the accompanying drawings: Figure 6 A flowchart illustrating yet another implementation of step S301 provided in an embodiment of this application. For example... Figure 6 As shown, when performing entity alignment on the problem to be processed and obtaining the entity alignment result, step S301 may further include the following steps S601-S603: S601. Determine whether there is a preset reference type in the problem to be processed; Among them, the preset referential type is either a pronoun or an omitted entity. For example, the question to be processed, "What are its capabilities?" contains the pronoun "it"; the question to be processed, "Where are they distributed?" omits the subject entity. These cases both belong to the preset referential type.
[0107] S602. If they exist, then based on the problem to be processed, historical problems, and the reference entity list, bind the pronouns or omitted entities in the problem to be processed with the entities in the reference entity list to obtain the bound entities corresponding to the pronouns or omitted entities.
[0108] In this embodiment, a sliding window can be used to retain the most recent K rounds of dialogue, and the entity state across rounds can be maintained according to the order in which entities are mentioned in the K rounds of dialogue, thereby obtaining a reference entity list.
[0109] Specifically, the reference entity list is obtained through the following steps: obtaining the reference entity list corresponding to the current round of dialogue; if a new entity is identified in the current round of dialogue, updating the reference entity list according to the new entity, and using the updated reference entity list for entity binding in the next round of dialogue.
[0110] When a new entity is identified in the current round of dialogue, the reference entity list for the next round is updated. Specifically: At the start of a multi-turn dialogue, such as the first turn, the reference entity list can be initialized to empty. At the start of each turn, the reference entity list corresponding to the current turn must first be obtained; this list is inherited from the end of the previous turn. This reference entity list provides contextual constraints for referential disambiguation in the current turn.
[0111] During the processing of the current dialogue round, after entity alignment is completed, it is determined whether any new entities have appeared in the current dialogue round. When a new entity not previously present in the reference entity list is identified in the current dialogue round, an update operation is triggered on the reference entity list. Specifically, the reference entity list is updated based on the identified new entity, for example, by adding the new entity to the list. The updated reference entity list is then used for entity binding and disambiguation processing in the next dialogue round. If no new entities appear in the current dialogue round, the reference entity list remains unchanged, and the next dialogue round continues to inherit the current list.
[0112] It's important to note that when using a sliding window to retain the most recent K rounds of dialogue, if the window length is exceeded, the earliest dialogue record is discarded, but the reference entity from the previous round is retained until a new entity appears. This incremental maintenance mechanism, which triggers updates only when a new entity appears, allows for continuous tracking of the shift in topic focus across dialogue rounds. Furthermore, by avoiding including all irrelevant entities mentioned in each round of dialogue in the list, it effectively prevents the list from expanding indefinitely and interfering with the current focus. This provides dynamic and precise local contextual constraints for referential resolution, effectively preventing focus drift in long dialogues.
[0113] The following section provides a detailed explanation of the update mechanism for the reference entity list using a specific example: Round 1: Initialization and No-Referential Scenario User input: How to identify Maiasaura? Historical input: None Current list of referenced entities: {} (empty) The corresponding processing procedure is as follows: Entity Recognition: The problem to be processed is parsed, and the entity "Mama Dragon" is identified. Since there are no pronouns or omitted entities in the current problem to be processed (the pronoun type is judged as "none"), no binding operation is performed.
[0114] Entity alignment: Directly align the entities of "Mother Dragon".
[0115] List Update: A new entity, "Maiasaura," was identified in this round, but the updated list will be used for the next round. Therefore, the reference entity list for the next round will be updated to {Maiasaura}.
[0116] Round Two: Binding of Singular Prefix Pronouns User input: What capabilities does it have? Historical input: How to identify Maiasaura? Current reference entity list: {Maiasaura} (inherited from the previous round, this list is in effect) The corresponding processing procedure is as follows: Referential type judgment: The user input question contains the referential word "it", which is a first-class word: a referential word that represents singular or predicate.
[0117] Entity binding: According to the rules, the first category of words is bound to the first item in the reference entity list. The current first item in the list is "Maiasaura", so "it" is bound to "Maiasaura".
[0118] Entity alignment: The bound specific entity "Mother Dragon" will be used for subsequent entity alignment.
[0119] List Update: No new entities were found in this round of entity alignment (“Maiasaura” is already in the list), so the reference entity list remains unchanged, and the next round will still be {Maiasaura}.
[0120] Third round: Subject omission scenario User input: Where are they located? Historical input: How to identify Maiasaura? What were its abilities? Current reference entity list: {Maiasaura} (Not updated, still in effect) The corresponding processing procedure is as follows: Referential type judgment: The user input was found to lack a clear subject entity (third type of word: omitted entity).
[0121] Entity binding: According to the rules, the omitted entity is bound to the entire list of reference entities. The current list is {Maiasaura}, so the omitted subject is bound to "Maiasaura".
[0122] Entity alignment: Based on the binding result "Maiasaura", perform entity alignment and execute a query for the distribution location of Maiasaura.
[0123] List Update: No new entity was identified. The list remains unchanged, and the next round will still be {Maiasaura}.
[0124] Round 4: Identify new entities and trigger updates User input: Is sea lily a lily? Historical input: How to identify Maiasaura? What were its abilities? Where was it distributed? Current reference entity list: {Maiasaura} (Not updated, still in effect) The corresponding processing procedure is as follows: Reference type judgment: If the user input does not contain a pronoun or the entity is omitted, binding is not performed.
[0125] Entity alignment: Directly perform entity alignment to identify the new entity "Crinny".
[0126] List Update: A new entity, "Sea Lily," has been identified this round. According to the mechanism, an update operation will be triggered, adding the new entity "Sea Lily" to the reference entity list. The updated list {Sea Lily} will be used in the next round of dialogue.
[0127] Fifth round: New entity list takes effect and references are resolved User input: So where is it located? Historical input: How to identify a Maiasaura? Is a crinoid a lily? Current reference entity list: {Sea Lily} (This list will take effect after the fourth update) The corresponding processing procedure is as follows: Referential type judgment: The referential word "it" (first category word) was detected again.
[0128] Entity binding: According to the rules, "it" is bound to the first item {sea lily} in the new reference entity list, so "it" is correctly bound to "sea lily".
[0129] Entity alignment: Based on the binding result "sea lily", perform entity alignment and execute a query for the distribution location of sea lilies.
[0130] During the binding process, pre-set binding rules must be followed. For example, the reference entity list contains entities active in the current dialogue context, arranged in the order of mention. Once a pronoun in the problem to be addressed is identified, it needs to be visualized as one or more entities in the list, based on the category of the pronoun and the arrangement rules of the reference entity list, to obtain the bound entity corresponding to the pronoun or the omitted entity.
[0131] If a preset referential type is determined, then based on the question to be processed, the questions in the historical dialogue, and the reference entity list, the referential words or omitted entities in the question to be processed should be bound to the entities in the reference entity list.
[0132] Specifically, the pronouns or omitted entities in the problem to be processed are bound to entities in the reference entity list to obtain the bound entities corresponding to the pronouns or omitted entities, including at least one of the following: binding the first type of words in the problem to the first entity in the reference entity list to obtain the bound entities corresponding to the first type of words; the first type of words are pronouns representing singular or preceding reference; binding the second type of words in the problem to the last entity in the reference entity list to obtain the bound entities corresponding to the second type of words; the second type of words are pronouns representing following reference; binding the third type of words in the problem to the entire reference entity list to obtain the bound entities corresponding to the third type of words; the third type of words are pronouns representing plural, pronouns representing whole, or omitted entities.
[0133] For the first type of words, for example, when pronouns such as "it", "this", and "the former" are identified in the problem to be processed, since in a context where multiple entities are mentioned successively, the first item in the reference entity list usually corresponds to the most recently emphasized entity, binding the singular pronoun to that position conforms to the conventions of most natural language expressions. Therefore, in this case, the first type of words can be bound to the first entity in the reference entity list.
[0134] For the second type of words, such as the pronoun "the latter," in the discourse structure, it usually refers to the object that is later in the parallel structure. In the reference entity list arranged in the order of mention, it is the last item. Therefore, it is bound to the last item of the reference entity list.
[0135] For the third type of words, such as "they," "both," or "these," or when the subject entity is omitted in the current problem to be processed, it indicates that the scope of the problem is collective, rather than a single entity. In this case, the third type of words can be bound to all entities contained in the entire list of reference entities.
[0136] This embodiment provides deterministic disambiguation logic for machine processing of reference by clearly distinguishing different referential types such as "it / this," "the latter," and "they / omitted," and formulating precise rules for binding them to the first, last, or all items in a list. In this way, complex natural language referential phenomena can be accurately transformed into clear sets of entities, avoiding the ambiguity that may arise from relying solely on semantic understanding, and significantly improving the robustness of reference resolution in complex contexts such as the coexistence of multiple entities.
[0137] In some examples, entity binding can be accomplished using a large language model. The entity binding prompt template includes the task definition, analysis steps, and specific examples, enabling the large language model to perform entity binding. This prompt template can be as follows: "
Task
[0138]
Analysis Steps
[0139] If not, output an empty set {} directly; If so, proceed to step 2; Step 2: Identify the referential type If it is a specific entity name: output the entity directly, regardless of whether it is in the reference list; If it is a pronoun as described above or the subject is omitted: proceed to step 3; Step 3: Perform entity binding Pronouns such as "it / this / the former": bind the first item in the list of reference entities; Pronouns such as "the latter" are used to bind the last item in the list of referenced entities. Pronouns such as "they / both / these" or omitting the subject: bind the entire list of reference entities;
Example
[0140] Once the binding is complete, entity alignment can be performed on the problem to be processed based on the specific bound entity, transforming the originally vague references in the problem to be processed into clear entity names, thereby obtaining accurate entity alignment results.
[0141] This embodiment actively identifies the referential type in the question and enforces a binding operation with entities in the reference entity list, accurately converting ambiguous referentials or subject omissions into specific entity names. This removes semantic obstacles to entity alignment, effectively solving the referential ambiguity and focus drift problems that frequently occur in complex continuous interactions, ensuring the coherence and accuracy of multi-turn dialogues.
[0142] Continue reading Figure 3 After obtaining the entity alignment result corresponding to the problem to be processed through various implementation methods of step S301 above, the following step S302 can be executed to determine the target query type: S302. Based on the entity alignment results, determine the target query type corresponding to the problem to be processed.
[0143] Step S302 can be implemented in several ways, as follows: In some implementations, the target query type corresponding to the problem to be processed is determined based on the entity alignment result, including: if the entity alignment result includes a preset comparison operator, the target query type is determined to be the second query type; otherwise, the target query type is determined to be the first query type; the comparison operator is a symbol representing the numerical size relationship or equivalence relationship.
[0144] Specifically, by aligning entities to the problem to be processed, a corresponding entity alignment result can be obtained. This result reflects the entities, attributes, concepts mentioned in the problem and their logical relationships. When the entity alignment result contains a preset comparison operator, the target query type of the problem to be processed can be determined to be the second query type; otherwise, the target query type can be determined to be the first query type. This provides a reliable preliminary judgment basis for subsequent branch routing retrieval.
[0145] The preset comparison operator can be a symbol representing numerical size or equivalence, such as gt (greater than), lt (less than), or eq (equal to). When the entity alignment result contains the above preset comparison operator, it can be determined that the problem to be processed belongs to the second query type.
[0146] Specifically, the target query type can be determined based on whether the attribute values of the entities in the entity alignment result include a preset comparison operator. That is: determine whether the attribute values of the entities in the entity alignment result include a preset comparison operator; if the attribute values of the entities in the entity alignment result include the preset comparison operator, then the target query type is determined to be the second query type; otherwise, the target query type is determined to be the first query type.
[0147] In other implementations, the process of determining the target query type is not limited to the comparison-based approach described above. For example, a classification model can be pre-trained, and the entity alignment results of the question to be processed can be input into the classification model, which will directly output the predicted label of the query type; alternatively, a rule base storing the correspondence between typical question patterns and query types can be maintained, and the target query type can be determined through pattern matching.
[0148] The above embodiment describes the specific implementation process of step S201, which can obtain the target query type corresponding to the problem to be processed. Next, the specific implementation method of step S202 will be introduced: In some implementations of step S202, the query database corresponding to the first query type can be a knowledge graph database. The query database corresponding to the second query type can be an external search engine, such as Elasticsearch. Based on this, step S202 can further include: if the target query type is the first query type, then the question to be processed is routed to the knowledge graph database for information query to obtain the information query result corresponding to the first query type; or, if the target query type is the second query type, then the question to be processed is routed to the external search engine for information query to obtain the information query result corresponding to the second query type.
[0149] In this implementation, the knowledge graph database uses a graph data model to store and manage data, which includes nodes representing entities and edges representing relationships. This graph structure can express the relationships between entities. Therefore, when performing structured traversal queries such as querying the attributes of an entity, traversing other entities associated with an entity through specific relationships, or querying all instances under a concept, the graph traversal algorithm can obtain information query results with extremely high efficiency. Specifically, by mapping the entity alignment results to a knowledge graph database query language (such as Gremlin statements) and performing traversal, background knowledge can be accurately extracted, providing reliable data support for the subsequent enhancement and generation of large language models.
[0150] Among them, queries in the knowledge graph database include: pure entity query, pure concept query, entity-attribute query, concept-attribute query, and second-order entity query.
[0151] When the entity alignment result contains only entity mappings, it indicates a pure entity query, designed to retrieve basic information about one or more entities. For example, if the question is "Introduce a Triceratops", the corresponding entity alignment result would be (E-Triceratops).
[0152] When the entity alignment result contains only concept mappings, it is characterized as a pure concept query, aiming to query all subordinate entity sets under a single or multiple concept categories. For example, if the question is "What animals belong to the Pterosaur family?", the corresponding entity alignment result would be (C-Pterosaur family).
[0153] When the entity alignment result contains both entity and attribute combination mappings, it is characterized as an entity-attribute query, supporting basic attribute queries, comparisons, and basic judgments. For example, if the problem to be processed is "Which is heavier, Tyrannosaurus Rex or Triceratops?", the corresponding entity alignment result is (E-Tyrannosaurus Rex)&(P-weight)|(E-Triceratops)&(P-weight).
[0154] When the entity alignment result is a combination of concept and attribute mapping, it represents a concept-attribute query, which is an attribute aggregation query for batch entities. For example, if the question to be processed is "What is the typical body length of an ankylosaur?", the corresponding entity alignment result is (C-Ankylosaur)&(P-Body Length).
[0155] When the entity alignment result contains a progressive mapping relationship of "entity-relationship-attribute", it is characterized as a second-order entity query, which aims to complete the association derivation based on multi-level relationship links. For example, if the question to be processed is "What is the weight of the prey of Tyrannosaurus Rex?", the corresponding entity alignment result is (E-Tyrannosaurus Rex) & (P-predation relationship); (P-weight).
[0156] The external search engine employs a combined index structure that integrates inverted indexes and dense vector indexes. The inverted index efficiently supports keyword-based text matching and numerical range queries, while the dense vector index supports vector retrieval based on semantic similarity. This combined index structure gives the external search engine significant performance advantages when performing complex computational tasks such as numerical range queries, extreme value sorting, and semantically matched attribute value reverse queries.
[0157] This embodiment uses a divide-and-conquer database routing architecture to execute regular structured queries and complex logical reasoning queries by the underlying engine best suited to their characteristics, so that different types of query requests can obtain optimal execution efficiency and processing capabilities.
[0158] To further support the efficient execution of complex logical reasoning queries, in this embodiment, the second query type may include at least one of a numerical range query type, an extreme value query type, and an attribute value reverse query type. The external retrieval engine includes attribute records corresponding to each entity, and these attribute records include numerical attribute range value fields for each entity, used to support the second query type. Routing the question to be processed to the external retrieval engine for information querying to obtain the information query result corresponding to the second query type includes: based on the entities and attributes in the question to be processed, performing an information query of the second query type under the corresponding numerical attribute range value field in the external retrieval engine, and obtaining the information query result corresponding to the second query type.
[0159] The numerical range query type is used to handle problems with threshold constraints, such as finding entities whose attribute values are greater than, less than, or fall within a certain numerical range. The extreme value query type is used to find entities corresponding to the maximum or minimum value of an attribute. The attribute value reverse query type is used to filter target entities based on the text description of the attribute value.
[0160] Specifically, when a quantitative threshold constraint is detected in the problem to be processed, it is identified as a numerical range query. In this case, the inverted index and Block K-Dimensional Tree (BKD) structure of the Elasticsearch database can be used to retrieve the set of entities under a specified concept whose target attributes satisfy a specific numerical range within milliseconds. For example, for the question "What dinosaurs weighed more than 9 tons?", the entity alignment results are: (P - weight) & (V - gt - 9 tons), (C - dinosaur). By constructing Elasticsearch query code that includes boolean queries and range filters, the retrieval is performed, and the entity names and their corresponding attribute values that meet the numerical range constraint are returned.
[0161] When a query containing limiting conditions such as maximum, minimum, heaviest, or fastest is detected, it is identified as an extreme value query. In this case, extreme value optimization can be transformed into sorting the numerical attribute value fields (numbers) in descending / ascending order, directly retrieving the first result, thus achieving target locking within seconds. For example, for the question "Which dinosaur has the largest weight?", the entity alignment results are: (P - weight) & (V - eq - maximum); (C - dinosaur). Information can be retrieved by constructing Elasticsearch query code that includes sorting logic and a size=1 constraint, returning the optimal entity and its attribute values that match the extreme value conditions.
[0162] When the aggregated pending issues detects target entities that are filtered in reverse based on textual attribute features, it is identified as an attribute value reverse query. At this point, the `function_score` mechanism can be used to weightedly fuse the text matching score and the vectorized semantic similarity score, achieving accurate reverse filtering of target entities. This mechanism overcomes the limitations of literal matching while being compatible with synonymous expressions and fuzzy descriptions in natural language. For example, for the question "What are some herbivorous dinosaurs?", the entity alignment results are: (P-dietary) & (V-eq-herbivorous); (C-dinosaur). A comprehensive query request (Elasticsearch query code) can be constructed that integrates the `match` text query and the `elastiknn_nearest_neighbors` vector retrieval to perform information retrieval and return the entity group matching the behavioral habits and corresponding attribute descriptions.
[0163] To store the necessary numerical information in a structured manner within the external search engine to support the second query type, the external search engine's index structure includes attribute records corresponding to each entity. Each entity's attribute record contains a numeric attribute range field to support the second query type.
[0164] Specifically, when the second query type is a numeric range query, the query process may include: locating the data record with the corresponding attribute in the external search engine based on the entity and attribute identified in the question; and performing a range query on its numeric attribute range value field (numbers field). For example, for the question "What dinosaurs weighed more than 9 tons?", the entity alignment results include (P-weight) and (V-gt-9 tons). Then, "9 tons" is converted to the standard value 9.0, and a range query is performed on the numeric attribute range value field in all data records with the concept "dinosaur" and the attribute "weight" to filter out records whose numeric range contains or is greater than 9.0.
[0165] When the second query type is an extreme value query, the query process may include: transforming the extreme value optimization task into a sorting operation on the numeric attribute range value field (numbers field). For example, for the question "Which dinosaur has the largest weight?", the numbers field can be sorted in descending order within the range of concept "dinosaur" and attribute "weight", and the size parameter can be set to 1 to return only the first and first results after sorting, thereby identifying the dinosaur entity with the largest weight.
[0166] This embodiment utilizes a method of setting up a dedicated numerical attribute range field for attribute records within the external search engine. This allows complex logic such as determining numerical ranges and sorting extreme values to be directly transformed into numerical calculations at the underlying level of the external search engine. Consequently, complex numerical queries can fully leverage the capabilities of efficient numerical indexing structures such as BKD trees. Compared to the approach of reading attribute values one by one from the knowledge graph and then performing numerical comparisons and sorting at the application layer, this solves the problem of traditional graphs' inefficient handling of numerical calculations and improves query efficiency.
[0167] To enable external search engines to effectively support complex queries, each data record in the external search engine can be set as a single attribute corresponding to each entity. Referring again to Table 1, using its specific index structure as an example, the entity "Tyrannosaurus Rex" in the knowledge graph database was originally a single node containing multiple attributes (such as name, weight, diet, and length). In the external search engine, each attribute of this entity is split into an independent index record. For example, "Tyrannosaurus Rex - Name", "Tyrannosaurus Rex - Weight", "Tyrannosaurus Rex - Diet", and "Tyrannosaurus Rex - Length" each form a separate data record, each containing fields such as name (entity name), property (attribute name), value (attribute value), and numbers (numerical attribute range values).
[0168] This embodiment transforms traditional entity-centric coarse-grained storage into a fine-grained indexing storage method based on attributes. This allows queries targeting specific attributes to directly locate relevant records without needing to retrieve and parse the entity's complete information, reducing the overhead of reading irrelevant data. Furthermore, numeric attribute range fields (numbers) must be bound to specific properties, ensuring that numeric range queries and extreme value queries are precisely targeted at the target attribute field without interference from other non-numeric attributes. This effectively supports functions such as numeric attribute range queries, extreme value queries, and reverse attribute value queries.
[0169] Furthermore, this embodiment also supports cascading combinations of multiple parsing types. For example, for the question "What is the largest carnivorous dinosaur found?", the entity alignment result is "(P-weight)&(V-eq-largest);(P-diet)&(V-eq-carnivorous);(C-dinosaur)". First, it determines the existence of a comparison operator, triggering a complex logical reasoning branch, and routes to the Elasticsearch database: It performs a reverse attribute value lookup, filtering out the set of entities with the concept 'dinosaur' and the diet 'carnivorous'; then, it performs an extreme value lookup on the returned candidate entity set, sorting the weight value range field in descending order and taking the first value, ultimately locking in the target entity.
[0170] In some embodiments, for pre-processing divide-and-conquer retrieval, i.e., for each piece of background knowledge retrieved through two branches—conventional graph query and complex logical reasoning—structured source metadata (including entity ID, entity name, associated concept ID, and attribute name / value) is automatically appended. This ensures that the natural language answer generated by the large language model can be accurately traced back to the original structured triples in the graph, thereby constructing a complete data loop of "knowledge retrieval - enhanced generation - verification and checking," guaranteeing high credibility and interpretability in industrial-grade application scenarios.
[0171] For example, in a conventional graph retrieval (entity-attribute query), if the question to be processed is: How long is a Tyrannosaurus Rex?, the entity alignment result is: (E-Tyrannosaurus Rex)&(P-body length), and the knowledge and traceability information is: (E001-Tyrannosaurus Rex, body length, about 12 meters).
[0172] For example, in a conventional graph retrieval (second-order entity query), if the question to be processed is: What is the weight of the prey of Tyrannosaurus Rex?, the entity alignment result is: (E-Tyrannosaurus Rex) & (P-predation relationship); (P-weight). Then the knowledge and traceability information is: (E001-Tyrannosaurus Rex, predation relationship, E002-Triceratops), (E002-Triceratops, weight, about 9 tons).
[0173] The question-and-answer processing method provided in this application has the following beneficial effects: (1) Using Elasticsearch to build a hybrid index system that includes inverted index, numerical range and vector, the graph attributes are finely decomposed and stored, realizing the paradigm shift from "full memory loading" to "on-demand index retrieval", fundamentally avoiding the risk of memory overflow when loading large-scale graph data.
[0174] (2) By combining “dynamic few sample example filtering” with “structured short code protocol”, Top-N highly relevant examples are injected at the input end through vector semantic adaptive injection, and the length of the output result of the large language model is compressed by short code at the output end, thereby improving the entity alignment accuracy and reducing the inference latency.
[0175] (3) Through the collaborative mechanism of “historical reference entity tracking” and “referential entity binding”, the former maintains the entity state across rounds, and the latter performs referential disambiguation in the current round, thereby ensuring accurate referential disambiguation and semantic completion in a private computing environment with limited computing power.
[0176] (4) By constructing a routing system for “regular graph query” and “complex logical reasoning”, complex reasoning such as numerical range query, extreme value query, and attribute value reverse query is pushed down to the ES engine for execution, and high-order compound reasoning question answering is supported by the cascading combination of multiple parsing types.
[0177] (5) By constructing an end-to-end response latency optimization strategy from the dimensions of “input-output-computing power-scheduling”, an extremely low response latency is achieved while ensuring industrial-grade question answering accuracy.
[0178] Specifically, on the input side, by adopting a dynamic few-sample filtering strategy, the traditional static full-sample injection is abandoned. Only a small number of highly relevant examples are assembled as needed, which greatly reduces the length of prompt words input to the large language model and reduces the reasoning burden of the large language model from the source.
[0179] On the output side, the lengthy natural language output is transformed into a high-density logical expression through a structured alignment short code protocol, which compresses the amount of tokens generated by the large language model in the entity alignment stage and reduces the generation latency of the large language model.
[0180] On the computing power side, for real-world business scenarios where private computing power is limited, deploying a large language model with INT8 quantization can maximize the basic inference throughput.
[0181] On the scheduling side, non-streaming calls are used in the entity alignment phase to ensure that the complete alignment result is obtained before proceeding to the subsequent process; while streaming calls are used in the question and answer generation phase to return the answer token to the user in real time, improving the user's perceived response speed.
[0182] By bidirectional token compression at both the input and output ends, quantization acceleration of the underlying model, and perception optimization at the application layer, the average first response time can be controlled within 2 seconds while ensuring entity alignment and question-and-answer quality. Compared with the existing fusion solution (which takes about 6 to 8 seconds), the overall latency reduction reaches more than 70%, which can achieve dual guarantees of question-and-answer quality and real-time interaction.
[0183] Exemplary device Corresponding to the above-mentioned problem-solving methods, this application also provides a question-and-answer processing device. Figure 7 This is a schematic diagram of the structure of a question-and-answer processing device provided in an embodiment of this application. Figure 7As shown in the embodiment of this application, the question-and-answer processing device includes: a determining unit 701, a querying unit 702, and a replying unit 703; wherein, the determining unit 701 is used to determine the target query type corresponding to the user-input question to be processed; the target query type is a first query type or a second query type, and the query logic complexity of the second query type is higher than that of the first query type; the querying unit 702 is used to route the question to be processed to the query database corresponding to the target query type for information querying according to the target query type, and obtain the information query result under the query database corresponding to the target query type; the query database corresponding to the first query type is used to process structured queries, and the query database corresponding to the second query type is used to process logical reasoning queries, and the complexity of logical reasoning queries is higher than that of structured queries; the replying unit 703 is used to generate reply content for the question to be processed according to the information query result.
[0184] In some embodiments, the determining unit 701 determines the target query type corresponding to the user-input question to be processed, specifically including: performing entity alignment on the question to be processed to obtain an entity alignment result; and determining the target query type corresponding to the question to be processed based on the entity alignment result.
[0185] In some embodiments, when determining unit 701 performs entity alignment on the problem to be processed to obtain entity alignment results, it specifically includes: obtaining a candidate schema set; the candidate schema set includes skeleton elements pre-loaded into a knowledge graph database in memory, and candidate entities related to the problem to be processed selected from an external search engine; the skeleton elements include the concepts, attributes, and relationships of each entity in the knowledge graph database; the external search engine includes each entity in the knowledge graph database; and performing entity alignment on the problem to be processed according to the candidate schema set to obtain the entity alignment results.
[0186] In some embodiments, the external retrieval engine includes attribute records corresponding to each entity. Each attribute record includes an attribute name field, an attribute value field, and a vectorized representation of the corresponding attribute value. Each entity's single attribute corresponds to one data record. Candidate entities are obtained through the following steps: Preliminary screening entities are selected from the external retrieval engine whose attribute name field values are preset content and whose text matching score with the question to be processed is greater than a preset threshold. A semantic similarity score is determined between the preliminary screening entities and the question to be processed based on the vectorized representation of the preliminary screening entities and the vectorized representation of the question to be processed. A comprehensive matching score is obtained between the preliminary screening entities and the question to be processed based on a weighted fusion of the text matching score and the semantic similarity score. The N preliminary screening entities with the highest comprehensive matching scores are selected as candidate entities, where N is a positive integer.
[0187] In some embodiments, the determining unit 701 performs entity alignment on the problem to be processed according to the candidate schema set to obtain an entity alignment result, including: generating a prompt word template for entity alignment according to the candidate schema set; performing entity alignment on the problem to be processed according to the prompt word template through a large language model to obtain an original alignment result, and converting the original alignment result into a structured alignment result based on a preset shortcode specification; and determining the final entity alignment result according to the structured alignment result.
[0188] In some embodiments, the determining unit 701 is further configured to select M target sample examples with the highest similarity to the problem to be processed from a preset sample example library; where M is a positive integer; and to perform entity alignment on the problem to be processed based on the M target sample examples and the candidate schema set to obtain the entity alignment result.
[0189] In some embodiments, the sample example library includes each sample question and its corresponding entity alignment result; wherein, the determining unit 701 selects the M target sample examples with the highest similarity to the user-input question from the preset sample example library, including: calculating the similarity between each sample question and the question to be processed; and determining the M sample questions with the highest similarity and their corresponding entity alignment results as the M target sample examples.
[0190] In some embodiments, the determining unit 701 performs entity alignment on the problem to be processed to obtain an entity alignment result, including: determining whether there is a preset referential type in the problem to be processed; the preset referential type is a pronoun or an omitted entity; if there is, based on the problem to be processed, historical problems, and a reference entity list, binding the pronoun or omitted entity in the problem to be processed with the entity in the reference entity list to obtain the bound entity corresponding to the pronoun or omitted entity; and performing entity alignment on the problem to be processed according to the bound entity to obtain the entity alignment result.
[0191] In some embodiments, the reference entity list is obtained by the following steps: obtaining the reference entity list corresponding to the current round of dialogue; if a new entity is identified in the current round of dialogue, updating the reference entity list according to the new entity, and using the updated reference entity list for entity binding in the next round of dialogue.
[0192] In some embodiments, binding pronouns or omitted entities in the problem to be processed to entities in the reference entity list to obtain bound entities corresponding to the pronouns or omitted entities includes at least one of the following: binding a first type of word in the problem to the first entity in the reference entity list to obtain a bound entity corresponding to the first type of word; the first type of word is a pronoun representing singularity or prefiguration; binding a second type of word in the problem to the last item in the reference entity list to obtain a bound entity corresponding to the second type of word; the second type of word is a pronoun representing postfiguration; binding a third type of word in the problem to the entire reference entity list to obtain a bound entity corresponding to the third type of word; the third type of word is a pronoun representing plurality, a pronoun representing wholeness, or an omitted entity.
[0193] In some embodiments, the determining unit 701 determines the target query type corresponding to the problem to be processed based on the entity alignment result, including: if the entity alignment result includes a preset comparison operator, then the target query type is determined to be the second query type; otherwise, the target query type is determined to be the first query type; the comparison operator is a symbol representing a numerical size relationship or equivalence relationship.
[0194] In some embodiments, the query database corresponding to the first query type is a knowledge graph database; the query database corresponding to the second query type is an external retrieval engine; the external retrieval engine adopts a joint index structure combining inverted index and dense vector index; wherein, the query unit 702 routes the question to be processed to the query database corresponding to the target query type for information query based on the target query type, and obtains the information query result under the query database corresponding to the target query type, including: if the target query type is the first query type, then the question to be processed is routed to the knowledge graph database for information query, and obtains the information query result corresponding to the first query type; or, if the target query type is the second query type, then the question to be processed is routed to the external retrieval engine for information query, and obtains the information query result corresponding to the second query type.
[0195] In some embodiments, the first query type is a structured query based on the entity; the second query type includes at least one of a numerical range query type, an extreme value query type, and an attribute value reverse query type; the external retrieval engine includes attribute records corresponding to each entity, and the attribute records include numerical attribute range value fields for each entity to support the second query type; wherein, the query unit 702 routes the problem to be processed to the external retrieval engine for information query to obtain the information query result corresponding to the second query type, including: performing the information query of the second query type under the corresponding numerical attribute range value field in the external retrieval engine according to the entity and attribute in the problem to be processed, to obtain the information query result corresponding to the second query type.
[0196] In some embodiments, each data record in the external retrieval engine corresponds to a single attribute of each entity.
[0197] The problem-handling apparatus provided in this embodiment belongs to the same application concept as the problem-handling method provided in the above embodiments of this application. It can execute the problem-handling method provided in any of the above embodiments of this application and has the corresponding functional modules and beneficial effects for executing the problem-handling method. Technical details not described in detail in this embodiment can be found in the specific processing content of the problem-handling method provided in the above embodiments of this application, and will not be repeated here.
[0198] The functions implemented by the determination unit 701, query unit 702 and response unit 703 can be implemented by the same or different processors, and this application embodiment does not limit them.
[0199] It should be understood that the units in the above device can be implemented by a processor calling software. For example, the device includes a processor connected to a memory containing instructions. The processor calls the instructions stored in the memory to implement any of the above methods or to implement the functions of each unit in the device. The processor can be a general-purpose processor, such as a CPU or microprocessor, and the memory can be internal or external to the device. Alternatively, the units in the device can be implemented as hardware circuits. By designing the hardware circuits, some or all of the unit functions can be implemented. The hardware circuits can be understood as one or more processors. For example, in one implementation, the hardware circuit is an ASIC, and the functions of some or all of the above units are implemented by designing the logical relationships between the components within the circuit. In another implementation, the hardware circuit can be implemented using a PLD, such as an FPGA, which can include a large number of logic gates. The connection relationships between the logic gates are configured through configuration files to implement the functions of some or all of the above units. All units in the above device can be implemented entirely by a processor calling software, entirely by hardware circuits, or partially by a processor calling software with the remaining parts implemented by hardware circuits.
[0200] In this application embodiment, a processor is a circuit with signal processing capabilities. In one implementation, the processor can be a circuit with instruction reading and execution capabilities, such as a CPU, microprocessor, GPU, or DSP. In another implementation, the processor can implement certain functions through the logical relationships of hardware circuits. These logical relationships are fixed or reconfigurable. For example, the processor may be a hardware circuit implemented as an ASIC or PLD, such as an FPGA. In a reconfigurable hardware circuit, the process of the processor loading a configuration document and configuring the hardware circuit can be understood as the processor loading instructions to implement the functions of some or all of the above units. Furthermore, it can also be a hardware circuit designed for artificial intelligence, which can be understood as an ASIC, such as an NPU, TPU, or DPU.
[0201] As can be seen, each unit in the above device can be one or more processors (or processing circuits) configured to implement the above methods, such as: CPU, GPU, NPU, TPU, DPU, microprocessor, DSP, ASIC, FPGA, or a combination of at least two of these processor forms.
[0202] Furthermore, the units in the above devices can be integrated in whole or in part, or they can be implemented independently. In one implementation, these units are integrated together and implemented in the form of a System-on-Chip (SoC). The SoC may include at least one processor for implementing any of the above methods or implementing the functions of the units in the device. The at least one processor may be of different types, such as CPU and FPGA, CPU and artificial intelligence processor, CPU and GPU, etc.
[0203] Exemplary electronic devices This application provides an electronic device, see [link to relevant documentation] Figure 8 As shown, the electronic device includes: Memory 200 and processor 210; The memory 200 is connected to the processor 210 and is used to store programs; The processor 210 is configured to implement the problem-solving method disclosed in any of the above embodiments by running the program stored in the memory 200.
[0204] Specifically, the aforementioned electronic device may also include: a bus, a communication interface 220, an input device 230, and an output device 240.
[0205] The processor 210, memory 200, communication interface 220, input device 230, and output device 240 are interconnected via a bus. Among them: A bus can include a pathway for transmitting information between various components of a computer system.
[0206] Processor 210 can be a general-purpose processor, such as a general-purpose central processing unit (CPU), a microprocessor, etc., or an application-specific integrated circuit (ASIC), or one or more integrated circuits used to control the execution of the program of the present invention. It can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), an off-the-shelf programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0207] Processor 210 may include a main processor, as well as a baseband chip, modem, etc.
[0208] The memory 200 stores a program that executes the technical solution of this invention, and may also store an operating system and other key business functions. Specifically, the program may include program code, which includes computer operation instructions. More specifically, the memory 200 may include read-only memory (ROM), other types of static storage devices capable of storing static information and instructions, random access memory (RAM), other types of dynamic storage devices capable of storing information and instructions, disk storage, flash memory, etc.
[0209] Input device 230 may include a device for receiving user input data and information, such as a keyboard, mouse, camera, scanner, light pen, voice input device, touch screen, pedometer, or gravity sensor.
[0210] Output device 240 may include devices that allow information to be output to a user, such as a display screen, printer, speaker, etc.
[0211] The communication interface 220 may include a device that uses any transceiver to communicate with other devices or communication networks, such as Ethernet, Radio Access Network (RAN), Wireless Local Area Network (WLAN), etc.
[0212] The processor 210 executes the program stored in the memory 200 and calls other devices, which can be used to implement the various steps of any of the problem-solving methods provided in the above embodiments of this application.
[0213] This application also proposes a chip including a processor and a data interface. The processor reads and runs a program stored in a memory through the data interface to execute the problem-solving method described in any of the above embodiments. For details of the processing and its beneficial effects, please refer to the embodiments of the problem-solving method described above.
[0214] Exemplary computer program products and storage media In addition to the methods and devices described above, embodiments of this application may also be computer program products, which include computer program instructions that, when executed by a processor, cause the processor to perform the steps in the problem-solving methods according to various embodiments of this application as described in any of the above embodiments of this specification.
[0215] The computer program product can be written in any combination of one or more programming languages to perform the operations of the embodiments of this application. The programming languages include object-oriented programming languages such as Java and C++, as well as conventional procedural programming languages such as C or similar languages. The program code can be executed entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.
[0216] Furthermore, embodiments of this application may also be storage media storing a computer program, which is executed by a processor of the steps in the problem-solving methods according to various embodiments of this application as described in any of the foregoing embodiments of this specification.
[0217] For the foregoing method embodiments, in order to simplify the description, they are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, because according to this application, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0218] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For apparatus embodiments, since they are basically similar to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.
[0219] The steps in the methods of the various embodiments of this application can be adjusted, merged, or deleted in order according to actual needs, and the technical features described in each embodiment can be replaced or combined.
[0220] The modules and sub-modules in the various embodiments of the present application's devices and terminals can be merged, divided, and deleted according to actual needs.
[0221] It should be understood that the disclosed terminals, devices, and methods can be implemented in other ways, given the several embodiments provided in this application. For example, the terminal embodiments described above are merely illustrative. For instance, the division of modules or sub-modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple sub-modules or modules may be combined or integrated into another module, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or modules, and may be electrical, mechanical, or other forms.
[0222] The modules or submodules described as separate components may or may not be physically separate. The components that constitute a module or submodule may or may not be physical modules or submodules; that is, they may be located in one place or distributed across multiple network modules or submodules. Some or all of the modules or submodules can be selected to achieve the purpose of this embodiment's solution, depending on actual needs.
[0223] Furthermore, the functional modules or sub-modules in the various embodiments of this application can be integrated into one processing module, or each module or sub-module can exist physically separately, or two or more modules or sub-modules can be integrated into one module. The integrated modules or sub-modules described above can be implemented in hardware or in the form of software functional modules or sub-modules.
[0224] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0225] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software unit executed by a processor, or a combination of both. The software unit can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0226] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0227] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A question-and-answer processing method, characterized in that, include: Determine the target query type corresponding to the user's input question to be processed; The target query type is either a first query type or a second query type, and the query logic complexity of the second query type is higher than that of the first query type. Based on the target query type, the problem to be processed is routed to the query database corresponding to the target query type for information query, and the information query results under the query database corresponding to the target query type are obtained; the query database corresponding to the first query type is used to process structured queries, and the query database corresponding to the second query type is used to process logical reasoning queries, wherein the complexity of logical reasoning queries is higher than that of structured queries. Based on the information query results, a response is generated for the question to be processed.
2. The method according to claim 1, characterized in that, Determine the target query type corresponding to the user-inputted problem, including: Perform entity alignment on the problem to be processed to obtain the entity alignment result; Based on the entity alignment results, determine the target query type corresponding to the problem to be processed.
3. The method according to claim 2, characterized in that, The entity alignment of the problem to be processed is performed to obtain the entity alignment result, including: Obtain a candidate schema set; the candidate schema set includes skeleton elements from a knowledge graph database pre-loaded into memory, and candidate entities related to the problem to be processed selected from an external search engine; the skeleton elements include the concepts, attributes, and relationships of each entity in the knowledge graph database; the external search engine includes each entity in the knowledge graph database; The entity alignment of the problem to be processed is performed based on the candidate schema set to obtain the entity alignment result.
4. The method according to claim 3, characterized in that, The external search engine includes attribute records corresponding to each entity. Each attribute record includes an attribute name field, an attribute value field, and a vectorized representation of the corresponding attribute value for each entity. Each entity's single attribute corresponds to one data record. The candidate entities are obtained through the following steps: The external search engine filters out entities whose attribute name field values are preset content and whose text matching score between the attribute value and the problem to be processed is greater than a preset threshold. Based on the vectorized representation of the preliminarily screened entity and the vectorized representation of the problem to be processed, determine the semantic similarity score between the preliminarily screened entity and the problem to be processed; The comprehensive matching score between the initially screened entity and the problem to be processed is obtained by weighted fusion of the text matching score and the semantic similarity score. The N entities with the highest comprehensive matching scores are selected as candidate entities; where N is a positive integer.
5. The method according to claim 3, characterized in that, Based on the candidate schema set, entity alignment is performed on the problem to be processed to obtain the entity alignment result, including: Based on the candidate schema set, generate entity-aligned prompt word templates; The large language model performs entity alignment on the problem to be processed according to the prompt word template to obtain the original alignment result, and then converts the original alignment result into a structured alignment result based on the preset shortcode specification. Based on the structured alignment result, the final entity alignment result is determined.
6. The method according to claim 3, characterized in that, The method further includes: Select the M target sample examples with the highest similarity to the problem to be processed from the preset sample example library; where M is a positive integer; Specifically, entity alignment is performed on the problem to be processed based on the candidate schema set to obtain the entity alignment result, including: Based on the M target sample examples and the candidate schema set, entity alignment is performed on the problem to be processed to obtain the entity alignment result.
7. The method according to claim 6, characterized in that, The sample example library includes various sample questions and their corresponding entity alignment results; Specifically, the M target sample examples with the highest similarity to the user-input question are selected from a pre-defined sample example library, including: Calculate the similarity between each sample problem and the problem to be processed; The M sample questions with the highest similarity and their corresponding entity alignment results are determined as the M target sample examples.
8. The method according to claim 2, characterized in that, The entity alignment process for the problem to be processed, to obtain the entity alignment result, includes: Determine whether a preset referential type exists in the problem to be processed; the preset referential type is a pronoun or an omitted entity. If they exist, based on the problem to be processed, historical problems, and the reference entity list, the pronouns or omitted entities in the problem to be processed are bound to the entities in the reference entity list to obtain the bound entities corresponding to the pronouns or omitted entities. Based on the bound entities, the entity alignment of the problem to be processed is performed to obtain the entity alignment result.
9. The method according to claim 8, characterized in that, The list of reference entities is obtained through the following steps: Get the list of reference entities corresponding to the current round of dialogue; If a new entity is identified in the current round of dialogue, the reference entity list is updated according to the new entity, and the updated reference entity list is used for entity binding in the next round of dialogue.
10. The method according to claim 8, characterized in that, The step of binding the pronouns or omitted entities in the problem to be processed with entities in the reference entity list to obtain the bound entities corresponding to the pronouns or omitted entities includes at least one of the following: The first type of words in the problem to be processed are bound to the first entity in the reference entity list to obtain the bound entity corresponding to the first type of words; the first type of words are pronouns that represent singular or forward reference. The second type of words in the problem to be processed are bound to the last item of the reference entity list to obtain the bound entity corresponding to the second type of words; The second category of words consists of pronouns that indicate what follows; The third type of words in the problem to be processed are bound to the entire list of reference entities to obtain the bound entities corresponding to the third type of words; the third type of words are pronouns representing plurals, pronouns representing wholes, or omitted entities.
11. The method according to claim 2, characterized in that, Based on the entity alignment results, the target query type corresponding to the problem to be processed is determined, including: If the entity alignment result includes a preset comparison operator, then the target query type is determined to be the second query type; otherwise, the target query type is determined to be the first query type. The comparison operator is a symbol that represents the numerical size relationship or equivalence relationship.
12. The method according to claim 1, characterized in that, The query database corresponding to the first query type is a knowledge graph database; the query database corresponding to the second query type is an external retrieval engine; the external retrieval engine adopts a composite index structure combining inverted index and dense vector index; Specifically, based on the target query type, the problem to be processed is routed to the query database corresponding to the target query type for information querying, and the information query results under the query database corresponding to the target query type are obtained, including: If the target query type is the first query type, then the problem to be processed is routed to the knowledge graph database for information query, and the information query result corresponding to the first query type is obtained; or, If the target query type is the second query type, the problem to be processed is routed to the external search engine for information querying, and the information query result corresponding to the second query type is obtained.
13. The method according to claim 12, characterized in that, The first query type is a basic structured query; the second query type includes at least one of the following: numerical range query type, extreme value query type, and attribute value reverse query type. The external search engine includes attribute records corresponding to each entity, and the attribute records include numeric attribute range value fields for each entity to support the second query type; Specifically, the problem to be processed is routed to the external search engine for information querying to obtain the information query results corresponding to the second query type, including: Based on the entities and attributes in the problem to be processed, perform the information query of the second query type under the corresponding numerical attribute range value field in the external search engine to obtain the information query result corresponding to the second query type.
14. The method according to claim 12, characterized in that, Each data record in the external search engine corresponds to a single attribute of each entity.
15. An electronic device, characterized in that, Including memory and processor; The memory is connected to the processor and is used to store programs; The processor is configured to implement the method as described in any one of claims 1 to 14 by running a program in the memory.
16. A question-and-answer system, characterized in that, include: Input processing unit, output processing unit, first query database, and second query database; The first query database is used to process structured queries, and the second query database is used to process logical reasoning queries, wherein the complexity of logical reasoning queries is higher than that of structured queries. The input processing unit is used to determine the target query type corresponding to the user-input question to be processed; The target query type is either a first query type or a second query type, and the query logic complexity of the second query type is higher than that of the first query type. Based on the target query type, the problem to be processed is routed to the query database corresponding to the target query type for information query, and the information query results under the query database corresponding to the target query type are obtained; wherein, the first query type corresponds to the first query database, and the second query type corresponds to the second query database. The output processing unit is used to generate a response to the problem to be processed based on the information query results.
17. A computer program product, characterized in that, It includes computer program instructions that, when executed by a processor, cause the processor to perform the method as described in any one of claims 1 to 14.