Question and answer interaction method, device and electronic equipment

By constructing a pre-defined knowledge graph based on the relationships between different categories of corpus data, and using entity analysis and matching to form retrieval statements, the problem of inaccurate answers in automatic question-answering systems is solved, and efficient and accurate question-answering interaction is achieved.

CN115495560BActive Publication Date: 2026-06-09DMAI (GUANGZHOU) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DMAI (GUANGZHOU) CO LTD
Filing Date
2021-06-17
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing automated question-answering systems struggle to provide accurate answers, especially due to incomplete knowledge graph coverage leading to inaccurate responses.

Method used

A pre-defined knowledge graph is constructed. Based on the relationships between different categories of corpus data, entity analysis and entity name set matching are used to form retrieval statements for accurate retrieval within the knowledge graph.

Benefits of technology

It improves the retrieval efficiency and accuracy of the question-answering system, providing accurate answers to different types of questions and expanding its application scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115495560B_ABST
    Figure CN115495560B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of natural language processing, in particular to a question and answer interactive method and device and electronic equipment, the interactive method comprises the following steps: obtaining a question to be processed and obtaining a preset knowledge graph, the preset knowledge graph is constructed based on the association relationship of corpus data of different categories; performing entity analysis on the question to be processed to determine a retrieval sentence corresponding to the question to be processed; and performing retrieval in the preset knowledge graph based on the retrieval sentence to determine an answer to the question to be processed. Since the preset knowledge graph is constructed according to the association relationship of corpus data of different categories, the preset knowledge graph has multiple category knowledge graphs, and the retrieval sentence obtained by performing entity analysis on the question to be processed can be used to perform retrieval in the preset knowledge graph, so that an accurate answer can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural language processing technology, and more specifically to question-and-answer interactive methods, devices, and electronic devices. Background Technology

[0002] Automated question answering is a technology that processes question text, analyzes user questions, and returns corresponding answers. However, due to the broad nature of language, questions can be phrased in countless ways, resulting in a wide variety of responses. In recent years, to reduce labor costs and improve user interactivity and experience, more and more automated question answering systems have emerged on the market, significantly reducing labor costs and user waiting time.

[0003] Current technologies typically construct knowledge graphs for different domains. This approach can lead to the inability to provide accurate and effective answers for knowledge that is not covered by the knowledge graph. For example, in a music knowledge graph question-answering system, if the question is asked: "What is the weather today?", the system might return the answer: "Sorry, I don't know." Summary of the Invention

[0004] In view of this, embodiments of the present invention provide a question-and-answer interactive method, apparatus, and electronic device to solve the problem that existing automatic question-and-answer systems are unable to provide accurate answers.

[0005] According to a first aspect, embodiments of the present invention provide a question-and-answer interactive method, including:

[0006] The system acquires the question to be processed and a preset knowledge graph, which is constructed based on the association relationships of different categories of corpus data.

[0007] Entity analysis is performed on the question to be processed to determine the corresponding search statement;

[0008] The search is performed on a preset knowledge graph based on the search query to determine the answer to the question to be processed.

[0009] The question-and-answer interaction method provided in this embodiment of the invention has multiple categories of knowledge graphs because the preset knowledge graph is constructed based on the association relationship of different categories of corpus data. The search statement obtained by entity analysis of the statement to be processed can be searched in the preset knowledge graph to retrieve the accurate answer.

[0010] In conjunction with the first aspect, in the first embodiment of the first aspect, the step of performing entity analysis on the question to be processed to determine the search statement corresponding to the question to be processed includes:

[0011] Obtain the entity naming set corresponding to the preset knowledge graph;

[0012] Based on the entity names in the entity naming set, the entity data in the question to be processed is determined by matching each entity name in the question to be processed.

[0013] Using the entity data in the question to be processed, determine the target question category to which the question to be processed belongs;

[0014] Based on the target question category and the entity data in the question to be processed, a retrieval statement corresponding to the question to be processed is formed.

[0015] The question-and-answer interactive method provided in this invention determines the entity data in the question to be processed by name matching, which can ensure the reliability of the entity data determination; at the same time, it determines the question category corresponding to the question to be processed to achieve accurate retrieval.

[0016] In conjunction with the first embodiment of the first aspect, in the second embodiment of the first aspect, the step of matching the entity names in the entity naming set with the entity names in the question to be processed to determine the entity data in the question to be processed includes:

[0017] The entity names in the entity naming set are used to match the query to be processed to obtain at least one matching entity;

[0018] Determine whether there are similar matching entities among the at least one matching entity;

[0019] When a similar matching entity exists among the at least one matching entity, the similar matching entities are filtered to determine the entity data in the question to be processed.

[0020] The question-and-answer interactive method provided in this invention filters similar matching entities when there are similar matching entities in the statement to be processed, which can reduce the amount of subsequent data retrieval processing and improve retrieval efficiency and accuracy.

[0021] In conjunction with the second embodiment of the first aspect, in the third embodiment of the first aspect, the step of filtering the similar matching entities to determine the entity data in the question to be processed includes:

[0022] The entity with the longest character length among the similar matching entities is retained, and other similar matching entities are deleted;

[0023] Extract the category corresponding to the entity with the longest character length to form the entity data in the question to be processed. The entity data includes the entity name and entity category.

[0024] In conjunction with the first embodiment of the first aspect, in the fourth embodiment of the first aspect, the step of forming a retrieval statement corresponding to the question to be processed based on the target question category and the entity data in the question to be processed includes:

[0025] By utilizing the correspondence between question categories and query statement templates, the target query statement template corresponding to the target question category is determined;

[0026] The target query template is populated based on the entity data to form the retrieval statement corresponding to the question to be processed.

[0027] The question-and-answer interactive method provided in this invention can determine the target query template corresponding to the statement to be processed by the correspondence between question categories and query statement templates, so as to accurately and efficiently retrieve the answer corresponding to the statement to be processed.

[0028] In conjunction with the first aspect, in the fifth embodiment of the first aspect, the step of obtaining the preset knowledge graph includes:

[0029] Acquire corpus data of multiple categories;

[0030] The preset knowledge graph is determined based on the categories of the corpus data and the relationships between the corpus data.

[0031] The question-and-answer interactive method provided in this invention utilizes the association between different categories of corpus data to construct a preset knowledge graph, enabling the preset knowledge graph to query different categories of questions and obtain answers to different categories of questions, thus expanding the application scenarios of the method.

[0032] In conjunction with the first aspect, or any one of the first to fifth embodiments of the first aspect, in the sixth embodiment of the first aspect, determining the preset knowledge graph based on the categories of the corpus data and the relationships between the corpus data includes:

[0033] Entities are extracted from the corpus data to construct an entity naming set, and there are relationships between different entities;

[0034] Obtain the preset entity category to construct the corresponding file, and store the entity in the corresponding file based on the category of each entity in the corpus data. The entity has a unique index in the file, and the unique index includes the entity's identifier and the entity's category identifier.

[0035] Based on the relationships between the different entities, the files corresponding to the preset entity categories are associated to determine the preset knowledge graph.

[0036] The question-and-answer interaction method provided in this invention utilizes the categories and attributes of entities and combines the relationships between different entities to construct a preset knowledge graph suitable for multi-category question queries. Furthermore, entities are stored in the preset knowledge graph using an index, which improves the efficiency of entity querying.

[0037] According to a second aspect, embodiments of the present invention also provide a question-and-answer interactive device, comprising:

[0038] The acquisition module is used to acquire the question to be processed and to acquire a preset knowledge graph, which is constructed based on the association relationship of different categories of corpus data;

[0039] The analysis module is used to perform entity analysis on the question to be processed and determine the search statement corresponding to the question to be processed.

[0040] The retrieval module is used to perform a retrieval in a preset knowledge graph based on the retrieval statement to determine the answer to the question to be processed.

[0041] The question-and-answer interactive device provided in this embodiment of the invention has multiple categories of knowledge graphs because the preset knowledge graph is constructed based on the association relationship of different categories of corpus data. The retrieval statement obtained by entity analysis of the statement to be processed can be searched in the preset knowledge graph to retrieve the accurate answer.

[0042] According to a third aspect, embodiments of the present invention provide an electronic device, including: a memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the question-and-answer interaction method described in the first aspect or any embodiment of the first aspect.

[0043] According to a fourth aspect, embodiments of the present invention provide a computer-readable storage medium storing computer instructions for causing the computer to perform the question-and-answer interactive method described in the first aspect or any embodiment of the first aspect. Attached Figure Description

[0044] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0045] Figure 1This is a flowchart of a question-and-answer interactive method according to an embodiment of the present invention;

[0046] Figure 2 This is a flowchart of a question-and-answer interactive method according to an embodiment of the present invention;

[0047] Figure 3 This is a flowchart of a question-and-answer interactive method according to an embodiment of the present invention;

[0048] Figure 4 This is a structural block diagram of a question-and-answer interactive device according to an embodiment of the present invention;

[0049] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0051] According to an embodiment of the present invention, a question-and-answer interactive method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0052] This embodiment provides a question-and-answer interactive method that can be used in electronic devices such as computers, mobile phones, tablets, and smart devices. Figure 1 This is a flowchart of a question-and-answer interactive method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:

[0053] S11, obtain the question to be processed and obtain the preset knowledge graph.

[0054] The preset knowledge graph is constructed based on the relationships between different categories of corpus data.

[0055] The question to be processed can be entered by the user on the interactive interface provided by the electronic device, captured by the electronic device using an audio acquisition device, or obtained by the electronic device from a third-party device, etc. There are no restrictions on the specific method by which the electronic device acquires the question to be processed; it can be configured according to actual needs.

[0056] There is no limit to the number of categories of corpus data included in the preset knowledge graph. The relationships between different categories of corpus data can be determined by the entities associated with each entity in the corpus. For example, if the entity is apple, and its related categories are fruit and company name, then using the entity apple, the categories of fruit and company name can be associated.

[0057] The preset knowledge graph can be obtained by the electronic device from the outside world, or it can be constructed by the electronic device using different types of corpus data, or it can be obtained through other means. There are no restrictions on it here, and the specific settings can be made according to actual needs.

[0058] Specifically, each node in the pre-defined knowledge graph can represent an entity, and the nodes store the attributes of each entity. Nodes can be connected using association relationships, which include not only association relationships between entities of the same category but also association relationships between entities of different categories.

[0059] The construction method of the preset knowledge graph will be described in detail below.

[0060] S12, perform entity analysis on the question to be processed to determine the search statement corresponding to the question to be processed.

[0061] After acquiring a question to be processed, the electronic device can first identify the individual phrases in the question, and then match these phrases with phrases in an entity database. This allows it to determine which phrases in the question belong to entities. The entity database can be built based on the names of entities in a pre-defined knowledge graph, or it can be established in other ways.

[0062] Alternatively, the electronic device can also remove some non-entity words from the statement to be processed. Accordingly, after removing the non-entity words, what remains in the statement to be processed are the entities.

[0063] After identifying the entities in the question to be processed, the electronic device can construct a search statement using the category to which the entity belongs. For example, if the analysis shows that the entity in the question belongs to the fruit category, then a search statement corresponding to the question can be formed using a question asking about fruit. Alternatively, the electronic device can also, based on identifying the entities in the question to be processed, determine the category to which the question belongs, obtain the question category, and use the question category to form a search statement.

[0064] The specifics of this step will be described below.

[0065] S13, based on the search query, search the preset knowledge graph to determine the answer to the question to be processed.

[0066] Once the electronic device has determined the search query, it can directly use that query to search within a pre-defined knowledge graph. As mentioned above, each node in the pre-defined knowledge graph stores the attributes of entities. Therefore, entity matching can be performed first within the pre-defined knowledge graph. After the entities are matched, the corresponding attributes can be extracted and output in conjunction with the question in the search query, thus determining the answer to the query to be processed.

[0067] The question-and-answer interaction method provided in this embodiment has multiple categories of knowledge graphs because the preset knowledge graph is constructed based on the association relationship of different categories of corpus data. The search statement obtained by the entity analysis of the statement to be processed can be searched in the preset knowledge graph to retrieve the accurate answer.

[0068] This embodiment provides a question-and-answer interactive method that can be used in electronic devices such as computers, mobile phones, tablets, and smart devices. Figure 2 This is a flowchart of a question-and-answer interactive method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:

[0069] S21, obtain the question to be processed and obtain the preset knowledge graph.

[0070] The preset knowledge graph is constructed based on the relationships between different categories of corpus data.

[0071] Please see details Figure 1 S11 of the illustrated embodiment will not be described again here.

[0072] S22, Perform entity analysis on the question to be processed to determine the corresponding search statement.

[0073] Specifically, S22 may include:

[0074] S221, Obtain the entity naming set corresponding to the preset knowledge graph.

[0075] After acquiring the preset knowledge graph, the electronic device can construct the entity naming set using the entity names corresponding to each node in the preset knowledge graph. Alternatively, the electronic device can acquire the corresponding entity naming set simultaneously with the preset knowledge graph. No specific limitations are placed on the method of acquiring the entity naming set; it can be configured according to actual needs.

[0076] Furthermore, as mentioned above, each entity belongs to a specific entity category, and correspondingly, an entity can belong to different categories. Therefore, entity name sets can be constructed based on entity categories. For example, entity name set 1 is constructed for entity category A; entity name set 2 is constructed for entity category B; entity name set 3 is constructed for entity category C; and so on, thus constructing the entity name sets corresponding to the preset knowledge graph.

[0077] S222, based on the entity names in the entity naming set, match them in the question to be processed to determine the entity data in the question to be processed.

[0078] Electronic devices can use string matching to match entities and obtain all entity data in the question to be processed. The entity data can include entities and their categories. Of course, electronic devices can also use other methods for entity matching, and no limitation is made here.

[0079] Specifically, the entity names in the entity name set are matched against the query to find a few entity names that appear in the query. Of course, it's also possible that none of them will be found. If none are found, it means that the entity in the query is empty. For example, if the entity name set is (Jay Chou, JJ Lin), and the query is "What songs does Jay Chou have?", then the entity "Jay Chou" will be extracted.

[0080] In some optional embodiments of this example, the questions to be processed can be standardized before matching. Since the forms of questions input by different users vary, standardizing the questions to be processed converts them into a uniform question format for easier subsequent processing.

[0081] For example, the specific processing flow is as follows:

[0082] a) Change all Chinese and English characters used by users to a uniform format;

[0083] b) Replace all instances of spaces with a value greater than 1 with empty spaces;

[0084] c) Change all capitalization to lowercase or uppercase;

[0085] d) Transform user input into a standardized and uniform format.

[0086] In some optional implementations of this embodiment, S222 may include:

[0087] (1) Use the entity names in the entity name set to match the question to be processed to obtain at least one matching entity.

[0088] Electronic devices can use string matching to perform entity matching in the entity name set to obtain at least one matching entity in the question to be processed.

[0089] (2) Determine whether there are similar matching entities among at least one matching entity.

[0090] The similar matching entities can be those in which one element is a component of the other, for example, apple and Apple Inc. In this case, it is necessary to filter the similar matching entities. That is, if at least one matching entity contains a similar matching entity, step (3) is executed; otherwise, step S223 is executed.

[0091] (3) Filter similar matching entities to determine the entity data in the question to be processed.

[0092] The specific filtering method can be user-defined. For example, retaining the entity with the longest string and deleting the rest, or retaining the entity with the shortest string and deleting the rest. Therefore, by filtering similar matching entities, the entity data in the question to be processed can be determined.

[0093] When similar matching entities exist in the statement to be processed, filtering the similar matching entities can reduce the amount of subsequent data retrieval processing and improve retrieval efficiency and accuracy.

[0094] As an optional implementation of this embodiment, step (3) above may include:

[0095] 3.1) Keep the entity with the longest character length among the similar matching entities and delete the other similar matching entities.

[0096] 3.2) Extract the category corresponding to the entity with the longest character length to form entity data in the question to be processed. The entity data includes entity name and entity category.

[0097] Continuing with the previous example, in this embodiment, the entity with the longest character length among the similar matching entities is considered as the entity in the question to be processed. For example, "Apple Inc." is considered as the entity in the question to be processed, while "Apple" is deleted.

[0098] As mentioned above, entity name sets can be constructed based on entity categories. Therefore, after identifying the entities in the question to be processed, their corresponding entity categories can be determined accordingly.

[0099] S223, using the entity data in the question to be processed, determine the target question category to which the question to be processed belongs.

[0100] Electronic devices can utilize entity categories in entity data to first filter the question to be processed according to its category. For example, if the question to be processed includes entities of three entity categories, the categories can be initially filtered in a preset knowledge graph, and then the question category can be further determined from the three filtered entity categories.

[0101] Alternatively, electronic devices can directly input the names of the entities in the question to be processed into the classification model for classification processing to obtain the target question category.

[0102] Alternatively, electronic devices can first use the entities in the question to perform an initial screening to determine the question category, and then use a classification model for a second screening. That is, the question can be first matched by rules or classified by a model, or rules can be matched first and then the model can be classified, ultimately determining the target question category of the question.

[0103] S224. Based on the target question category and the entity data in the question to be processed, a retrieval statement corresponding to the question to be processed is formed.

[0104] Once the electronic device determines the category of the target question, it can construct the corresponding search statement for the question to be processed.

[0105] In some optional implementations of this embodiment, S224 may include:

[0106] (1) Use the correspondence between question categories and query statement templates to determine the target query statement template corresponding to the target question category.

[0107] Electronic devices store the correspondence between question categories and query templates. Once the question category to be processed is determined, its corresponding query template is also determined. Accordingly, the target query template corresponding to the target question category can be obtained.

[0108] (2) Fill the target query statement template with entity data to form the retrieval statement corresponding to the question to be processed.

[0109] The electronic device fills the entity in the question to be processed into the target query statement template, and then obtains the retrieval statement corresponding to the question to be processed.

[0110] By identifying the correspondence between question types and query templates, the target query template corresponding to the statement to be processed can be determined, enabling accurate and efficient retrieval of the answer to the statement to be processed.

[0111] S23, based on the search query, perform a search in the preset knowledge graph to determine the answer to the question to be processed.

[0112] Please see details Figure 1 S13 of the illustrated embodiment will not be described again here.

[0113] The question-and-answer interaction method provided in this embodiment determines the entity data in the question to be processed by name matching, which can ensure the reliability of the entity data determination; at the same time, it determines the question category corresponding to the question to be processed to achieve accurate retrieval.

[0114] As an optional implementation of this embodiment, the electronic device uses a string matching algorithm to extract entities from the question to be processed in the entity naming set. If multiple similar matching entities are extracted, then the elements in the extraction results need to be verified. If an element is a subset of another element, then the current element is set as a stop word for filtering, and finally, key-value pairs of entities and entity categories are constructed, that is, the entity data.

[0115] Furthermore, the electronic device uses a matching rule that combines entities and templates for querying. The electronic device can match specific category rule templates according to the following rules. The rule content is as follows:

[0116] (1) For the case of a single entity

[0117] 1.1) Classify the questions based on entity categories to determine which question category the question to be processed may belong to;

[0118] 1.2) Segment the question according to entity and match the rule template.

[0119] 1.3) For cases with multiple entities of the same category, the processing rule can be to prioritize matching the entity at the end of the sentence. The specific reason is based on English grammar, where the entity at the end of the sentence is generally the core content.

[0120] (2) For the case of multiple entities

[0121] 2.1) Classification based on the combination of mixed entity categories

[0122] 2.2) Segment the question according to entity and match the rule template.

[0123] For the single-entity and multi-entity cases mentioned above, if rule matching fails, model matching classification can be used. The model can use two methods: single-model and multi-model fusion.

[0124] Furthermore, based on the classification results, specific query templates are obtained, and the entities are populated accordingly. If multiple entities are involved, cascading queries are required to obtain the complete query. The query is executed, and the corresponding question-and-answer results are returned. When displaying the question-and-answer results, template replies can be applied, or responses can be generated based on the model to populate the answers and return the results.

[0125] This embodiment provides a question-and-answer interactive method that can be used in electronic devices such as computers, mobile phones, tablets, and smart devices. Figure 3 This is a flowchart of a question-and-answer interactive method according to an embodiment of the present invention, such as... Figure 3 As shown, the process includes the following steps:

[0126] S31, obtain the question to be processed and obtain the preset knowledge graph.

[0127] The preset knowledge graph is constructed based on the relationships between different categories of corpus data.

[0128] Specifically, S31 above may include:

[0129] S311, acquire corpus data of multiple categories.

[0130] The goal is to obtain specific corpus data for different application scenarios, including entity data and relation data. The data format is {entity id, attribute 1, attribute 2, ..., attribute n, containing another type of entity information: {entity id, attribute 1, attribute 2, ..., attribute n}}. This corpus data can be obtained using web scraping.

[0131] S312, Based on the categories of corpus data and the relationships between corpus data, determine the preset knowledge graph.

[0132] The corpus data acquired by the electronic device carries its corresponding category and the relationships between different corpus data. Therefore, the electronic device can directly utilize the relationships between different corpus data to determine the preset knowledge graph.

[0133] Optionally, after acquiring the corpus data, the electronic device can perform data cleaning to remove garbled characters and obtain data in a standardized format. Specific methods include, but are not limited to, removing garbled characters, symbols from uncommon entity names, etc. Simultaneously, when checking for garbled characters, it is also necessary to determine whether an entity exists within them; if an entity exists, it needs to be extracted.

[0134] The process of cleaning data and removing unwanted characters can be achieved through the following steps:

[0135] a) If garbled characters or random symbols appear in the field, delete them.

[0136] b) Verify the entity names, check the correctness of the fields, and delete unnecessary entities.

[0137] In some optional embodiments of this example, S312 may include:

[0138] (1) Extract entities from the corpus data to construct an entity naming set, wherein there are relationships between different entities.

[0139] (2) Obtain the preset entity categories to construct the corresponding files, and store the entities in the corresponding files based on the categories of each entity in the corpus data.

[0140] The entity has a unique index in the file, and the unique index includes the entity's identifier and the entity's category identifier.

[0141] Specifically, a file is constructed for each entity category. The content of the file depends on the specific business scenario, and there are no restrictions on its content. Unless otherwise specified, all entity attribute fields of the original corpus data are retained.

[0142] (3) Based on the relationship between different entities, the files corresponding to the preset entity categories are associated to determine the preset knowledge graph.

[0143] Simultaneously, an entity relationship file is constructed. The format of the entity relationship in the file is: entity id1, entity id2, relationship value. A globally unique index id field can also be added to the current relationship to facilitate relationship lookup.

[0144] After obtaining files from all categories, use the batch import command to import the maintenance bureau files into the database, completing the construction of the preset knowledge graph.

[0145] By utilizing entity categories and their attributes, and combining the relationships between different entities, a pre-defined knowledge graph suitable for multi-category question queries is constructed. Furthermore, entities are stored in the pre-defined knowledge graph using an index, which improves the efficiency of entity querying.

[0146] S313, retrieve the question to be processed.

[0147] See details Figure 1 The description of obtaining the question to be processed in S11 of the illustrated embodiment will not be repeated here.

[0148] It should be noted that S311-S312 above can be completed before the question to be processed is obtained. Once the preset knowledge graph is constructed, it can be used directly after the question to be processed is obtained, without the need to construct the question to be processed every time it is obtained.

[0149] S32, Perform entity analysis on the question to be processed to determine the search statement corresponding to the question to be processed.

[0150] Please see details Figure 2 S22 of the illustrated embodiment will not be described again here.

[0151] S33, based on the search query, perform a search in the preset knowledge graph to determine the answer to the question to be processed.

[0152] Please see details Figure 2 S23 of the illustrated embodiment will not be described again here.

[0153] The question-and-answer interactive method provided in this embodiment utilizes the associations between different categories of corpus data to construct a preset knowledge graph, enabling the preset knowledge graph to query different categories of questions in order to obtain answers to different categories of questions, thus expanding the application scenarios of the method.

[0154] As a specific application example of this embodiment, data in the field of English music is collected, a knowledge graph database is constructed, and then automatic question answering is implemented. The specific implementation process is as follows:

[0155] 1) Obtain the raw music data. The data is divided into three files: album, playlist, and artist. All three files contain music entities, while album and playlist files contain style entities. First, the raw data is cleaned, extracting all entities. A separate file is built for each entity type, resulting in a total of five entity files: album, playlist, artist, music, and style. Finally, a globally unique index `id` field is generated based on the unique primary key `id` of each entity in the file and its category. Simultaneously, an entity relationship file is constructed, with the entity relationship format: entity `id1`, entity `id2`, relationship `value`. A globally unique index `id` field is also added to the current relationship to facilitate relationship lookup.

[0156] After obtaining all the files, use the batch import command to import the data files into the database, thus completing the construction of the knowledge graph.

[0157] 2) Obtain the user-inputted question and standardize it. Specifically, use a character replacement function to replace all commas, periods, and questions with English characters; change English abbreviations to non-abbreviated formats; change all spaces between words to 1; and change all letter cases to lowercase, so as to transform the user's question input into a uniform and standardized format.

[0158] 3) Based on the five entity relationship files mentioned above, extract the entity names and construct an entity name set. Simultaneously, use a string matching algorithm to perform entity command matching, filtering the matching results to remove entities whose names are part of another entity name. Extract the entity content to obtain the entity category, and then match the question to the specific category according to the question format. If no match is found, put the question into the classification model, ultimately obtaining the question format results and entity content.

[0159] 4) Obtain a specific database query statement template based on the component results, fill in the entity content, and obtain a complete database query statement.

[0160] 5) Execute the database query statement and return the corresponding Q&A response.

[0161] The actual results are as follows:

[0162] Question: do you know who's the singer of the song 95minutes alone

[0163] Answer: The singer who sings this song is Michael Jason.

[0164] Question:I want to know the album of erima singer's name

[0165] Answer: The singers of this album are Mela Mrane and Kcee OmarKrizbeatz.

[0166] The question-and-answer interactive method provided in this embodiment can target a specific English corpus, in the format: {entity id, attribute 1, attribute 2, ..., attribute n, containing another entity information: {entity id, attribute 1, ..., attribute n}}, and combine it with a knowledge graph to obtain classification results through a series of rules and models. Based on the entity content, a database query statement is obtained, the database is accessed, and the final answer is obtained. The preset knowledge graph provided in this embodiment is scalable and supports multi-entity queries, meeting complex business scenarios. Furthermore, it solves the security issue without requiring expensive servers, resulting in low hardware costs.

[0167] This embodiment also provides a question-and-answer interactive device for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0168] This embodiment provides a question-and-answer interactive device, such as... Figure 4 As shown, it includes:

[0169] The acquisition module 41 is used to acquire the question to be processed and to acquire a preset knowledge graph, which is constructed based on the association relationship of different categories of corpus data;

[0170] Analysis module 42 is used to perform entity analysis on the question to be processed and determine the search statement corresponding to the question to be processed;

[0171] The retrieval module 43 is used to perform a retrieval in a preset knowledge graph based on the retrieval statement to determine the answer to the question to be processed.

[0172] The question-and-answer interactive device provided in this embodiment has multiple categories of knowledge graphs because the preset knowledge graph is constructed based on the association relationship of different categories of corpus data. The search statement obtained by the entity analysis of the statement to be processed can be searched in the preset knowledge graph to retrieve the accurate answer.

[0173] In this embodiment, the question-and-answer interactive device is presented in the form of a functional unit. Here, a unit refers to an ASIC circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.

[0174] Further functional descriptions of the above modules are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0175] This invention also provides an electronic device having the above-described features. Figure 4 The question-and-answer interactive device shown.

[0176] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an electronic device provided in an optional embodiment of the present invention, such as... Figure 5 As shown, the electronic device may include: at least one processor 51, such as a CPU (Central Processing Unit), at least one communication interface 53, memory 54, and at least one communication bus 52. The communication bus 52 is used to enable communication between these components. The communication interface 53 may include a display screen or a keyboard; optionally, the communication interface 53 may also include a standard wired interface or a wireless interface. The memory 54 may be high-speed RAM (Random Access Memory) or non-volatile memory, such as at least one disk storage device. Optionally, the memory 54 may also be at least one storage device located remotely from the aforementioned processor 51. The processor 51 may be combined with... Figure 4 The described apparatus has an application program stored in memory 54, and the processor 51 calls the program code stored in memory 54 to perform any of the above method steps.

[0177] The communication bus 52 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The communication bus 52 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0178] The memory 54 may include volatile memory, such as random-access memory (RAM); the memory may also include non-volatile memory, such as flash memory, hard disk drive (HDD) or solid-state drive (SSD); the memory 54 may also include a combination of the above types of memory.

[0179] The processor 51 can be a central processing unit (CPU), a network processor (NP), or a combination of CPU and NP.

[0180] The processor 51 may further include a hardware chip. This hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL), or any combination thereof.

[0181] Optionally, memory 54 is also used to store program instructions. Processor 51 can invoke program instructions to implement the functions described in this application. Figures 1 to 3The question-and-answer interactive method shown in the embodiment.

[0182] This invention also provides a non-transitory computer storage medium storing computer-executable instructions that can execute the question-and-answer interactive method in any of the above-described method embodiments. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), random access memory (RAM), flash memory, hard disk drive (HDD), or solid-state drive (SSD), etc.; the storage medium may also include combinations of the above types of memory.

[0183] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.

Claims

1. A method of question and answer interaction, characterized by, include: The system acquires the question to be processed and a preset knowledge graph, which is constructed based on the association relationships of different categories of corpus data. Entity analysis is performed on the question to be processed to determine the corresponding search statement; Based on the search query, a search is performed in a preset knowledge graph to determine the answer to the question to be processed; The step of obtaining the preset knowledge graph includes: Acquire corpus data of various categories; acquire corpus data specific to different application scenarios, which specifically includes entity data and relation data, wherein the data format is {entity id, attribute 1, attribute 2, ..., attribute n, containing another type of entity information: {entity id, attribute 1, attribute 2, ..., attribute n}}; Entities are extracted from the corpus data to construct an entity naming set, and there are relationships between different entities; Obtain the corresponding file for the preset entity category, and store the entity and its attributes in the corresponding file based on the category of each entity in the corpus data. The entity has a unique index in the file, and the unique index includes the entity's identifier and the entity's category identifier. Based on the relationships between the different entities, the files corresponding to the preset entity categories are associated to determine the preset knowledge graph; The entity analysis of the question to be processed to determine the corresponding search statement includes: Obtain the entity naming set corresponding to the preset knowledge graph; Based on the entity names in the entity naming set, the entity data in the question to be processed is determined by matching each entity name in the question to be processed. Using the entity data in the question to be processed, determine the target question category to which the question to be processed belongs; Based on the target question category and the entity data in the question to be processed, a retrieval statement corresponding to the question to be processed is formed; The process of matching entity names from the entity naming set against the query to be processed to determine entity data in the query includes: The entity names in the entity naming set are used to match the query to be processed to obtain at least one matching entity; Determine whether there are similar matching entities among the at least one matching entity; When a similar matching entity exists among the at least one matching entity, the similar matching entities are filtered to determine the entity data in the question to be processed; The step of filtering the similar matching entities to determine the entity data in the question to be processed includes: The entity with the longest character length among the similar matching entities is retained, and other similar matching entities are deleted; Extract the category corresponding to the entity with the longest character length to form the entity data in the question to be processed. The entity data includes the entity name and entity category. The process of forming a retrieval statement corresponding to the question to be processed based on the target question category and the entity data in the question to be processed includes: By utilizing the correspondence between question categories and query statement templates, the target query statement template corresponding to the target question category is determined; The target query template is populated based on the entity data to form the retrieval statement corresponding to the question to be processed.

2. A question and answer interactive device, characterized by, Applying the question-and-answer interaction method described in claim 1 to perform question-and-answer, including: The acquisition module is used to acquire the question to be processed and to acquire a preset knowledge graph, which is constructed based on the association relationship of different categories of corpus data; The analysis module is used to perform entity analysis on the question to be processed and determine the search statement corresponding to the question to be processed. The retrieval module is used to perform a retrieval in a preset knowledge graph based on the retrieval statement to determine the answer to the question to be processed; The step of obtaining the preset knowledge graph includes: Acquire corpus data of multiple categories; Entities are extracted from the corpus data to construct an entity naming set, and there are relationships between different entities; Obtain the corresponding file for the preset entity category, and store the entity and its attributes in the corresponding file based on the category of each entity in the corpus data. The entity has a unique index in the file, and the unique index includes the entity's identifier and the entity's category identifier. Based on the relationships between the different entities, the files corresponding to the preset entity categories are associated to determine the preset knowledge graph.

3. An electronic device, comprising: include: The system includes a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the question-and-answer interactive method as described in claim 1.

4. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the question-and-answer interactive method as described in claim 1.