WO2021098876A1 - 一种基于知识图谱的问答方法及装置 - Google Patents
一种基于知识图谱的问答方法及装置 Download PDFInfo
- Publication number
- WO2021098876A1 WO2021098876A1 PCT/CN2020/130820 CN2020130820W WO2021098876A1 WO 2021098876 A1 WO2021098876 A1 WO 2021098876A1 CN 2020130820 W CN2020130820 W CN 2020130820W WO 2021098876 A1 WO2021098876 A1 WO 2021098876A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- entity
- query
- natural
- question
- sentence
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
- G06F16/3329—Natural language query formulation or dialogue systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/903—Querying
- G06F16/9032—Query formulation
- G06F16/90332—Natural language query formulation or dialogue systems
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
- G06F40/35—Discourse or dialogue representation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/33—Querying
- G06F16/332—Query formulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/36—Creation of semantic tools, e.g. ontology or thesauri
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/30—Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
- G06F16/36—Creation of semantic tools, e.g. ontology or thesauri
- G06F16/367—Ontology
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/90—Details of database functions independent of the retrieved data types
- G06F16/903—Querying
- G06F16/9032—Query formulation
- G06F16/90324—Query formulation using system suggestions
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/237—Lexical tools
- G06F40/247—Thesauruses; Synonyms
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/20—Natural language analysis
- G06F40/279—Recognition of textual entities
- G06F40/289—Phrasal analysis, e.g. finite state techniques or chunking
- G06F40/295—Named entity recognition
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F40/00—Handling natural language data
- G06F40/30—Semantic analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N5/00—Computing arrangements using knowledge-based models
- G06N5/02—Knowledge representation; Symbolic representation
Definitions
- This application relates to the field of information processing technology, and in particular to a question and answer method and device based on a knowledge graph.
- the terminal can use the knowledge graph to accurately and quickly obtain the answers to the questions asked by the user in natural language. Specifically, after obtaining the question input by the user, the terminal converts the question into a computer query language, and queries information from the knowledge graph according to the computer query language to obtain the answer to the question.
- the terminal when a user inputs a question with complete semantics, the terminal can find the answer to the question according to the knowledge graph.
- the terminal cannot convert the question into a computer query language, and thus cannot obtain the answer to the question.
- the present application provides a question and answer method and device based on a knowledge graph, which effectively solves the problem that the terminal cannot query the result of a natural query sentence that does not have complete semantics in the knowledge graph.
- this application provides a question answering method based on a knowledge graph.
- the question answering device based on the knowledge graph obtains a first natural query sentence including a first query entity and first entity feature information, wherein the first entity feature information includes At least one of the attribute of the first query entity or the relationship of the first query entity.
- the question answering device queries the knowledge graph to obtain the first result according to the first query entity and the characteristic information of the first entity, and outputs the first result.
- the question answering device obtains the second natural query sentence, and determines the missing part of the obtained second natural query sentence according to the first query entity or the characteristic information of the first entity. In this way, the question answering device searches the knowledge graph to obtain the second result according to the determined missing part of the second natural query sentence, and outputs the second result.
- the terminal when receiving a natural query sentence with incomplete semantics (such as the second natural query sentence in this application) input by the user, the terminal can combine the historical query entity and historical entity characteristic information (such as The first query entity and the first entity feature information in this application) complete the semantics of the current natural query sentence. Further, the terminal searches the knowledge graph according to the natural query sentence after semantic perfection, and outputs the result to the user.
- a natural query sentence with incomplete semantics such as the second natural query sentence in this application
- the terminal can combine the historical query entity and historical entity characteristic information (such as The first query entity and the first entity feature information in this application) complete the semantics of the current natural query sentence. Further, the terminal searches the knowledge graph according to the natural query sentence after semantic perfection, and outputs the result to the user.
- the existing question answering system only establishes a one-to-one relationship mapping network in the database, and the connection between the knowledge points and the knowledge points is very weak, so the answers fed back to the users are often inaccurate.
- the question and answer method based on the knowledge graph provided in this application can quickly and accurately feedback answers to users, and effectively solve the problem that the terminal cannot obtain the query results of natural query sentences that do not have complete semantics.
- the question answering device after acquiring the first natural query sentence, the question answering device further identifies the first query entity and the first entity characteristic information in the first natural query sentence, and stores the first natural query sentence. 1. Query the entity and the characteristic information of the first entity.
- the question and answer device stores the first query entity and the characteristic information of the first entity.
- the question and answer device can query the result of the natural query sentence according to the first query entity and the first entity characteristic information. .
- the question answering device before determining the missing part of the second natural query sentence according to the first query entity or the characteristic information of the first entity, the question answering device also determines that the second natural query sentence is missing the first 2. Query the feature information of the entity or the second entity.
- the second entity characteristic information includes at least one of the attribute of the second query entity or the relationship of the second query entity.
- the question answering device determines the second query entity according to the first query entity. If it is determined that the second natural query sentence lacks the second entity characteristic information, the question answering device determines the second entity characteristic information according to the first entity characteristic information.
- the question answering device When it is determined that the second natural query sentence is missing, the question answering device combines the first query entity or the characteristic information of the first entity to determine the missing part of the second natural query sentence. In this way, the missing part of the second natural query sentence can be determined based on the missing part of the second natural query sentence. Partial and second natural query sentences are used to determine a query sentence with a complete sentence.
- the method for the “question answering device to determine that the second natural query sentence is missing the second query entity or the second entity characteristic information” includes: the question answering device recognizes according to preset rules The query entity and entity characteristic information in the second natural query sentence are used to obtain the second query entity or the second entity characteristic information.
- the question answering device does not obtain the second query entity, it is determined that the second natural query sentence is missing the second query entity. If the question answering device does not obtain the second entity characteristic information, it is determined that the second natural query sentence lacks the second entity characteristic information.
- the above-mentioned "Q&A device recognizes the query entity and entity characteristic information in the second natural query sentence according to preset rules, so as to obtain the second query entity or the second entity
- the method of "characteristic information" includes: the question and answer device inputs the second natural query sentence into the first preset model to obtain the initial query entity or initial entity characteristic information of the second natural query sentence.
- the question answering device expands the initial query entity according to the preset algorithm and the second natural query sentence. Then, the question answering device obtains the second query entity according to the preset dictionary and the expanded initial query entity. If the initial entity feature information is obtained, the question answering device expands the initial entity feature information according to the preset algorithm and the second natural query sentence. Then, the question answering device obtains the second entity feature information according to the dictionary and the expanded initial entity feature information.
- the dictionary corresponds to the knowledge graph.
- the question and answer device in this application When the question and answer device in this application recognizes the query entity and entity characteristic information in the natural query sentence, it may first use the first preset model to identify the initial query entity and the initial entity characteristic information, and then compare the initial query entity and the initial entity characteristic information according to the preset algorithm. The entity feature information is expanded, and then combined with the preset dictionary tree, the question answering device determines the final query entity and entity feature information. Compared with the method in the prior art that directly uses a dictionary tree to identify query entities and entity feature information in natural query sentences, the present application has higher accuracy in identifying query entities and entity feature information.
- the question answering device uses a preset question model to determine the question of the second natural query sentence based on the second query entity, the second entity characteristic information, and the second natural query sentence Types of.
- the question answering device simplifies the process of converting the natural query sentence into the knowledge graph query sentence in the prior art by determining the question type of the natural query sentence, and improves the user experience.
- the above method of "the question answering device searches the knowledge graph to obtain the second result according to the missing part of the second natural query sentence" includes: The missing parts of the natural query sentence and the second natural query sentence determine the problem template of the second natural query sentence. Then, the question answering device determines the target query sentence in the preset question template library. The target query sentence corresponds to the target question template, and the target question template is a template in the question template library that has the greatest similarity with the question template of the second natural query sentence. Then, the question answering device searches the knowledge graph to obtain the second result according to the determined question type of the second natural query sentence and the target query sentence.
- the question template library includes m (m is a positive integer) question templates and m query statements, and each query statement in the m query statements uniquely corresponds to a question template.
- the question and answer device determines the query sentence through the question template library, which simplifies the process of converting the natural query sentence into the knowledge graph query sentence in the prior art, and improves the user experience.
- the question and answer device after determining the second query entity and the second entity characteristic information, the question and answer device further stores the second query entity and the second entity characteristic information.
- the question and answer device is also based on the first query entity, the feature information of the first entity, the missing part of the second natural query sentence, the second natural query sentence, and a preset guiding strategy , Determine the guiding sentence, and output the guiding sentence.
- the introductory sentence is used to guide the user's next operation.
- the question answering device can guide and recommend the user according to the user's historical query information and the guidance strategy, which improves the interactive experience between the user and the question answering device.
- this application provides a question and answer device based on a knowledge graph.
- the question and answer device includes: an acquisition unit, an inquiry unit, an output unit, and a determination unit.
- the above-mentioned acquiring unit is configured to acquire a first natural query sentence, the first natural query sentence including a first query entity and first entity characteristic information, and the first entity characteristic information includes an attribute of the first query entity or a relationship between the first query entity At least one of them.
- the above-mentioned query unit is configured to query the knowledge graph to obtain the first result according to the first query entity and the characteristic information of the first entity.
- the output unit outputs the first result inquired by the query unit.
- the above-mentioned obtaining unit is also used to obtain the second natural query sentence.
- the above determining unit is configured to determine the missing part of the second natural query sentence according to the first query entity or the characteristic information of the first entity.
- the query unit is further configured to query the knowledge graph to obtain the second result according to the missing part of the second natural query sentence determined by the determining unit.
- the output unit is also used to output the second result inquired by the query unit.
- the question and answer device further includes a storage unit configured to store the first query entity and the characteristic information of the first entity.
- the above determining unit is further configured to determine the second natural query sentence before determining the missing part of the second natural query sentence according to the first query entity or the characteristic information of the first entity.
- the natural query sentence lacks the second query entity or the second entity characteristic information, and the second entity characteristic information includes at least one of the attribute of the second query entity or the relationship of the second query entity.
- the above determining unit is specifically configured to determine the second query entity according to the first query entity if the second natural query sentence lacks the second query entity.
- the above determining unit is further specifically configured to determine the second entity characteristic information according to the first entity characteristic information if the second natural query sentence lacks the second entity characteristic information.
- the question answering device further includes an identification unit, and the above-mentioned identification unit is configured to identify the query entity and entity characteristic information in the second natural query sentence according to a preset rule, In order to obtain the second query entity or the characteristic information of the second entity.
- the determining unit is specifically configured to determine that the second natural query sentence lacks the second query entity if the recognition unit does not obtain the second query entity; if the recognition unit does not obtain the second entity characteristic information, determine the second natural query sentence The feature information of the second entity is missing.
- the identification unit is specifically configured to: input the second natural query sentence into the first preset model to obtain the initial query entity or initial entity characteristic information; if the initial query is obtained Entity, the initial query entity is expanded according to the preset algorithm and the second natural query sentence, and the second query entity is obtained according to the preset dictionary and the expanded initial query entity; if the initial entity characteristics are obtained Information, the initial entity feature information is expanded according to the preset algorithm and the second natural query sentence, and the second entity feature information is obtained according to the dictionary and the expanded initial entity feature information; wherein the dictionary corresponds to the knowledge graph.
- the above determination unit is further configured to determine the second natural query by using a preset problem model based on the second query entity, the feature information of the second entity, and the second natural query sentence The question type of the query statement.
- the above determining unit is further used to determine the question template of the second natural query sentence based on the second natural query sentence and the missing part of the second natural query sentence.
- the above determination unit is also used to determine the target query sentence in the preset question template library; the question template library includes m question templates and m query sentences, each of the m query sentences uniquely corresponds to a question template , M is a positive integer.
- the target query sentence corresponds to the target question template, and the target question template is: a template in the question template library with the greatest similarity to the question template of the second natural query sentence.
- the query unit is further configured to query the knowledge graph to obtain the second result according to the question type and target query sentence of the second natural query sentence determined by the determination unit.
- the above-mentioned storage unit is also used to store the second query entity and the characteristic information of the second entity.
- the above-mentioned determining unit is further used to determine the missing part of the second natural query sentence, the second natural query sentence, and the preset
- the guiding strategy determines the guiding sentence, which is used to guide the user's next operation.
- the output unit is also used to output the introductory sentence determined by the determining unit.
- the present application provides a question and answer device based on a knowledge graph
- the question and answer device includes: a memory and one or more processors; the memory and the processor are coupled; the memory is also used to store computer program code, the computer program The code includes computer instructions, and when the computer instructions are executed by the question answering device, the question answering device executes the question answering method as described in the first aspect and any one of its possible design methods.
- the present application provides a chip system that is applied to a question and answer device based on a knowledge graph; the chip system includes one or more interface circuits and one or more processors; the interface circuit and the processor are connected through a line The interface circuit is used to receive a signal from the memory of the question and answer device and send the signal to the processor.
- the signal includes a computer instruction stored in the memory; when the processor executes the computer instruction, the question and answer device executes as the first The question and answer method described in the aspect and any of its possible design methods.
- the present application provides a non-volatile storage medium.
- the non-volatile storage medium includes computer instructions.
- the question-and-answer device When the computer instructions run on a question-and-answer device based on a knowledge graph, the question-and-answer device is implemented as the first The question and answer method described in the aspect and any of its possible design methods.
- the present application provides a computer program product, which when the computer program product runs on a computer, causes the computer to execute the question and answer method based on the knowledge graph as described in the first aspect and any of its possible design methods.
- Fig. 1 is a schematic diagram 1 of the structure of the knowledge graph in an embodiment of the application
- Fig. 2 is a second schematic diagram of the structure of the knowledge graph in an embodiment of the application.
- FIG. 3 is a schematic diagram of the hardware structure of a question answering device based on a knowledge graph provided by an embodiment of the application;
- FIG. 4 is a schematic flowchart 1 of a question and answer method based on a knowledge graph provided by an embodiment of the application;
- FIG. 5 is a schematic diagram 1 of an example of a display interface provided by an embodiment of the application.
- FIG. 6 is a second schematic diagram of an example of a display interface provided by an embodiment of the application.
- FIG. 7 is a second schematic flowchart of a question and answer method based on a knowledge graph provided by an embodiment of this application.
- FIG. 8 is a third schematic diagram of an example of a display interface provided by an embodiment of the application.
- FIG. 9 is a schematic structural diagram of a question and answer device based on a knowledge graph provided by an embodiment of the application.
- FIG. 10 is a schematic structural diagram of a chip system provided by an embodiment of the application.
- FIG. 11 is a schematic structural diagram of a computer program product provided by an embodiment of the application.
- words such as “exemplary” or “for example” are used as examples, illustrations, or illustrations. Any embodiment or design solution described as “exemplary” or “for example” in the embodiments of the present application should not be construed as being more preferable or advantageous than other embodiments or design solutions. To be precise, words such as “exemplary” or “for example” are used to present related concepts in a specific manner.
- first and second are only used for descriptive purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined with “first” and “second” may explicitly or implicitly include one or more of these features. In the description of this application, unless otherwise specified, “plurality” means two or more.
- the knowledge graph is a structured semantic knowledge base, and its basic unit is the "entity, relationship, entity” triplet, or the "entity, attribute, attribute value” triplet.
- the attribute value can also be understood as a constant entity.
- the knowledge graph is usually composed of nodes and edges. Nodes represent entities or attribute values, and edges represent attributes or relationships. In the knowledge graph, edges connect various nodes to form a network structure. Among them, each node corresponds to a unique identity (identity, ID), and each edge corresponds to a unique identity.
- ID identity
- ID unique identity
- the knowledge graph can be applied to related scenarios such as knowledge reasoning, search, question and answer, and can make precise and refined answers.
- Fig. 1 shows the basic structure of the knowledge graph.
- the knowledge graph includes node 11, node 13, and node 14.
- Node 11 and node 13 are connected by edge 12, and node 11 and node 14 are connected by edge 15.
- node 11 represents entity A
- edge 12 represents relationship F
- node 13 represents entity B
- node 14 represents attribute value C
- edge 15 represents attribute J.
- the node 11, the edge 12, and the node 13 form a triple of "entity, relationship, entity", which is specifically used to indicate that "there is a relationship F between entity A and entity B”.
- the node 11, the node 14 and the edge 15 form a triple of "entity, attribute, attribute value", which is specifically used to indicate "the attribute value of the attribute J of the entity A is the attribute value C”.
- the entity in the embodiment of the present application may be a person's name, a place name, an occupation, and the like.
- the attributes can be height, weight, longitude, latitude, etc.
- the relationship can be father-son, father-son, mother-son, spouse, geographic area affiliation, etc. Among them, the father-son relationship can also include "son", "father” and other relationships.
- the entity can be character A (node 21), character C (node 22), and the relationship can be a father-daughter (side 23). Therefore, it is easy to know from Figure 2 that character A and character C have a father-daughter relationship .
- the entity can also be person B (node 24), location D (node 25), and the relationship can be the birthplace (edge 26). Therefore, it can be seen from FIG. 2 that person B was born at location D.
- the relationship can also be a husband and wife (side 29), so it can be seen that the person A and the person B are husband and wife.
- the attribute can be height (side 27), and the attribute value can be 180cm (node 28), so it is easy to know from Figure 2 that the height of character A is 180cm.
- Question answering system is an advanced form of information retrieval system.
- the question answering system can use accurate and concise natural language to answer users' questions in natural language.
- the terminal receives the natural language input by the user and converts the natural language problem input by the user into a machine query language through a natural language understanding (NLU) algorithm.
- NLU natural language understanding
- the terminal searches in the database according to the machine query language and returns results. Further, the terminal outputs the result to the user.
- Knowledge-based question answering system knowledge-based question answering
- Knowledge graph question answering system is a question answering system based on knowledge graph. Specifically, the user inputs a question expressed in natural language, and the terminal performs a semantic understanding of the question, and further transforms it into a knowledge graph query sentence. The terminal performs queries, inferences, etc. on the knowledge graph according to the knowledge graph query sentence, and returns the result. Finally, the terminal converts the result into natural language and outputs it to the user.
- the terminal can answer the questions raised by the user quickly, precisely and accurately.
- the question and answer method based on the knowledge graph question answering system can be implemented through the following steps:
- the terminal obtains a natural query sentence.
- the natural query sentence acquired by the terminal is a question expressed by the user through natural language and has complete semantics.
- the natural query sentence can clearly reflect the user's intention.
- the user inputs a natural query sentence "what is A's height" to the terminal.
- the terminal can analyze the user's intention, that is, the user wants to query A's height value.
- "what is the height of A” is a question with complete semantics.
- the terminal recognizes the query entity and entity characteristic information in the natural query sentence, and links the query entity and entity characteristic information to the knowledge graph.
- the terminal After acquiring the natural query sentence, the terminal first recognizes the query entity and entity characteristic information in the natural query sentence.
- the entity characteristic information is at least one of the attributes of the query entity and the relationship of the query entity.
- the terminal inputs the natural query sentence into the dictionary tree to obtain the query entity and entity characteristic information of the natural query sentence.
- the dictionary tree is constructed by the terminal in advance based on the dictionary.
- the terminal adopts an automata method to construct a dictionary tree based on the dictionary.
- the dictionary used to construct the dictionary tree can be a dictionary derived from the knowledge graph, or a dictionary generated from the data generated by the knowledge graph. In other words, the dictionary and the knowledge graph are corresponding.
- the terminal inputs the natural query sentence into the dictionary tree to obtain the query entity "A" and the attribute "height" of the query entity. If the natural query sentence is "Who is A's daughter?", the terminal inputs the natural query sentence into the dictionary tree, and the relationship between the query entity "A” and the query entity "daughter” can be obtained. If the natural query sentence is "What is the height of A's daughter?", the terminal enters the natural query sentence into the dictionary tree to obtain the query entity "A", the relationship "daughter" of the query entity, and the attributes of the query entity " height".
- the terminal After recognizing the query entity and entity feature information in the natural query sentence, the terminal links the recognized query entity and entity feature information to the knowledge graph.
- the terminal calculates the similarity between the identified query entity and each node in the knowledge graph, and links the query entity to the node with the greatest similarity to the query entity in the knowledge graph.
- the terminal Get the node's identification (such as ID).
- the terminal calculates the similarity between the identified entity feature information and each edge in the knowledge graph, and links the entity feature information to the edge in the knowledge graph with the greatest similarity to the entity feature information, correspondingly, The terminal obtains the identification (such as ID) of the edge.
- the terminal converts the natural query sentence into a knowledge graph query sentence, and queries the result in the knowledge graph according to the knowledge graph query sentence, and returns the result.
- the knowledge graph is stored in the form of a database. Therefore, when using the knowledge graph to query a natural query sentence, it is necessary to first convert the natural query sentence into a knowledge graph query sentence for the database, and then search the result from the knowledge graph according to the knowledge graph query sentence.
- the terminal converts the natural query sentence into a knowledge graph query sentence "select y from database where ⁇ A x> and ⁇ height y>". Further, the terminal replaces "A" and "height" in the knowledge graph query sentence with the ID of the node corresponding to the query entity in the knowledge graph and the ID of the edge corresponding to the entity feature information in the knowledge graph obtained by S2, and Query results from the knowledge graph. After the terminal finds the result in the knowledge graph, it returns the result.
- the terminal searches for the result in the knowledge graph according to "select ID height from database where ID(A)”, and finds that the value (that is, the attribute value) corresponding to the attribute of A (that is, the height) is "180cm”. Subsequently, the terminal will return "180cm”.
- the terminal outputs the query result.
- the terminal outputs the result returned by S3.
- the user asks question 1 "What is the height of A?” for the first time, and the terminal queries and obtains result 1 of question 1, and then outputs result 1 to the user. Later, out of normal language habits, the user may continue to ask question 2 "What about B?". In this case, what the user actually wants to know is the height of B. However, because question 2 only contains object B, the terminal cannot identify the real purpose of the user, and thus cannot find the result of the question for the user.
- the embodiments of the present application provide a question and answer method and device based on a knowledge graph.
- the terminal can combine the entity and feature information that has been stored in advance (such as the first query entity and the first entity feature information in the embodiment of the present application) to respond to the current question.
- the semantics of is improved.
- the terminal queries the knowledge graph based on the semantically improved questions, and outputs the query results to the user, effectively solving the problem that the terminal cannot obtain the query results of natural query sentences that do not have complete semantics.
- the question and answer method based on the knowledge graph provided by the embodiment of the application can be implemented by an application program installed on a terminal, such as a browser, an intelligent customer service of an electronic mall, a voice assistant, etc.
- the above-mentioned application program may be an embedded application program installed in the device (that is, a system application of the device), or a downloadable application program.
- an embedded application is an application provided as a part of the implementation of a device (such as a mobile phone).
- a downloadable application is an application that can provide its own Internet protocol multimedia subsystem (IMS) connection.
- the downloadable application is an application that can be pre-installed in the device or can be downloaded and installed by the user.
- Third-party applications in the device is an embedded application program installed in the device.
- the question answering device based on the knowledge graph provided by the embodiment of the present application may be a terminal.
- the terminal can be a portable device such as a mobile phone, a tablet computer, a wearable electronic device, or a device such as a vehicle-mounted device, a smart robot, or a personal computer (PC) or a personal digital assistant (personal digital assistant). , PDA), netbooks, servers and other computing devices.
- FIG. 3 shows a hardware structure of the question answering device 30 based on the knowledge graph in an embodiment of the present application.
- the question answering device 30 based on the knowledge graph includes a processor 31, a memory 32, a communication device 33, and a bus 34.
- the processor 31, the memory 32, and the communication device 33 may be connected by a bus 34.
- the processor 31 is the control center of the question answering device 30 based on the knowledge graph, and may be a general-purpose central processing unit (CPU) or other general-purpose processors. Among them, the general-purpose processor may be a microprocessor or any conventional processor.
- CPU central processing unit
- the general-purpose processor may be a microprocessor or any conventional processor.
- the processor 31 may include one or more CPUs, such as CPU 0 and CPU 1 shown in FIG. 3.
- the memory 32 may be a read-only memory (ROM) or other types of static storage devices that can store static information and instructions, random access memory (RAM), or other types that can store information and instructions
- ROM read-only memory
- RAM random access memory
- EEPROM electrically erasable programmable read-only memory
- magnetic disk storage media or other magnetic storage devices, or can be used to carry or store instructions or data structures
- the desired program code and any other medium that can be accessed by the computer but not limited to this.
- the memory 32 may exist independently of the processor 31.
- the memory 32 may be connected to the processor 31 through a bus 34, and is used to store data, instructions or program codes.
- the processor 31 calls and executes the instructions or program codes stored in the memory 32, it can implement the question and answer method based on the knowledge graph provided by the embodiment of the present application.
- the memory 32 may also be integrated with the processor 31.
- the communication device 33 is used to connect the question and answer device 30 based on the knowledge graph to other devices (such as clients, servers, etc.) through a communication network.
- the communication network may be an Ethernet or a radio access network (RAN), Wireless local area networks (WLAN), etc.
- the communication device 33 is specifically configured to receive data or send data, such as "obtain the first natural query sentence" in the embodiment of the present application.
- the communication device 33 may be a network interface or the like.
- the communication device 33 may be an antenna, a touch screen, a microphone, a speaker, and the like.
- the touch screen may specifically include a touch pad and a display screen.
- the touchpad can collect the touch events of the user of the portable device on or near it (for example, the user uses any suitable object such as a finger or a stylus to operate on the touchpad or near the touchpad), and The collected touch information is sent to other devices (for example, the processor 31).
- the user's touch event near the touchpad can be called floating touch; floating touch can mean that the user does not need to directly touch the touchpad in order to select, move or drag a target (such as an icon, etc.), but only The user is required to be near the device in order to perform the desired function.
- multiple types such as resistive, capacitive, infrared, and surface acoustic wave can be used to realize the touch panel.
- the display screen can be used to display information input by the user or information provided to the user and various menus of the portable device.
- the display can be configured in the form of liquid crystal display, organic light-emitting diode, etc.
- the touchpad can be overlaid on the display screen. When the touchpad detects a touch event on or near it, it will be sent to the processor 31 to determine the type of the touch event, and then the processor 31 can display the touch event according to the type of the touch event. Corresponding visual output is provided on the display.
- the bus 34 may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus.
- ISA Industry Standard Architecture
- PCI Peripheral Component Interconnect
- EISA Extended Industry Standard Architecture
- the bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one thick line is used in FIG. 3 to represent it, but it does not mean that there is only one bus or one type of bus.
- the structure shown in FIG. 3 does not constitute a limitation on the question answering device based on the knowledge graph.
- the question answering device 30 based on the knowledge graph may include more Or fewer parts, or a combination of some parts, or a different arrangement of parts.
- the terminal in the embodiment of the present application stores a knowledge graph, a first preset model, a second preset model, a dictionary tree, and a question template library.
- the first preset model used to identify entities and feature information in natural query sentences. Developers obtain the first preset model by marking a large number of natural language questions with entity and feature information, and performing data training.
- the second preset model (corresponding to the question model in the embodiment of the present application): used to classify natural query sentences. Developers obtain the second preset model by marking the question types of a large number of natural language questions and conducting data training.
- Dictionary tree used to identify query entities and entity feature information in natural query sentences. The construction of the dictionary tree can refer to the above description, which will not be described in detail here.
- Question template library It is composed of question templates and knowledge graph query sentences, and the question templates correspond to the knowledge graph query sentences. According to the natural query sentence template, the terminal can determine the knowledge graph query sentence corresponding to the natural query sentence from the question template library.
- FIG. 4 shows a schematic flowchart of a question and answer method based on a knowledge graph provided by an embodiment of the present application.
- the following description of the embodiments of the present application takes the question and answer device based on the knowledge graph as an example for description.
- the question answering method based on the knowledge graph includes the following steps:
- S401 The terminal obtains a first natural query sentence.
- the first natural query sentence is the first natural query sentence expressed by the user in natural language and input to the terminal in this session.
- the terminal is a portable device (such as a mobile phone)
- the user can manually input the first natural query sentence in the question and answer input box of the terminal.
- the terminal is a mobile phone as an example.
- the mobile phone obtains the first natural query sentence, and displays the first natural query sentence on the display interface of the mobile phone.
- the terminal is a portable device (such as a mobile phone)
- the user can input the first natural query sentence by voice.
- the terminal is a mobile phone as an example.
- the user operates the voice input icon 62 on the question and answer interface 61 displayed on the touch screen of the mobile phone, and inputs the first voice through the microphone.
- the user operates the voice input icon 62 on the question and answer interface 61 displayed on the touch screen of the mobile phone, and can either click the icon or long-press the icon, which is not limited in this application.
- the mobile phone acquires the first voice, and displays the first voice on the display interface of the mobile phone in the form of a voice bar, as shown in Figure 6 (b).
- the voice bar displayed on the display interface can also be converted into text and displayed on the display interface.
- the specific process of the mobile phone converting the first voice into text refers to the prior art, and the detailed description will not be repeated in the embodiment of the present application.
- the user wakes up the mobile phone through a wake-up word. Then, the user uses voice to input the first natural query sentence. For example, the user speaks the wake-up word "hello hello" to the mobile phone, and the mobile phone is woken up at this time. Subsequently, the terminal inputs the first voice through the microphone. In response to the user's operation, the mobile phone acquires the first voice, converts the first voice into text, and displays it on the display interface on the touch screen of the mobile phone.
- the terminal may receive the first natural query sentence input from the client through a network interface.
- the terminal recognizes the query entity and entity characteristic information of the first natural query sentence, and determines whether the first natural query sentence has complete semantics according to the recognition result.
- the entity characteristic information includes at least one of the relationship of the query entity and the attributes of the query entity.
- Manner 1 The process for the terminal to identify the query entity and entity characteristic information of the first natural query sentence can refer to the description of identifying the entity and characteristic information in S2, which will not be repeated here.
- Manner 2 After acquiring the first natural query sentence, the terminal inputs the first natural query sentence into the first preset model to obtain the initial entity and initial feature information of the first natural query sentence (in order to distinguish the query in S402 Entity and entity feature information, here, the entity obtained through the first preset model is referred to as the initial entity, and the feature information recognized through the first preset model is the initial feature information). Then, the terminal expands the number of words of the initial entity and initial feature information according to the preset algorithm and the first natural query sentence. Then, the terminal inputs the expanded initial entity and initial feature information into the dictionary tree to obtain the query entity and entity feature information of the first natural query sentence.
- the method for the terminal to expand the number of words of the initial entity and initial feature information may be as follows: the terminal calculates the initial entity and initial feature information according to the positions of the initial entity and initial feature information in the first natural query sentence. Entities and initial feature information are expanded by the number of words.
- the terminal can expand the initial entity and initial feature information to the left, or expand the initial entity and initial feature information to the right, and the terminal can also expand the initial entity and initial feature information to the left and right at the same time.
- the number of words that the terminal expands to the initial entity and initial feature information may be set by the terminal by default, or may be set by the user, which is not limited in the embodiment of the present application.
- the terminal obtains the first natural query sentence "How old is Wang Lanland?"
- the terminal inputs the first natural query sentence into the first preset model, and recognizes that the initial entity of the first natural query sentence is "Wang Lan ", the initial feature information (attribute) is "age”. If the preset number of extended words of the terminal is 1, the terminal determines to extend "Wang Lan” by 1 word to the right according to the position of "Wang Lan” in the first natural query sentence. Therefore, the original entity after expansion is "Wang Lanlan".
- the first natural query sentence acquired by the terminal is "Which is taller between A and B?", in this case, the query entities recognized by the terminal include “A” and "B".
- the query entities recognized by the terminal include "A” and "B".
- “A” is referred to as the primary query entity
- “B” is referred to as the secondary query entity.
- the first natural query sentence acquired by the terminal is "Which area of Beijing or Shanghai is large", in this case, the query entities recognized by the terminal include "Beijing" and "Shanghai".
- "Beijing” is referred to as the main query entity
- "Shanghai” is referred to as the secondary query entity.
- the primary query entity and the secondary query entity exist in a natural query statement at the same time.
- the secondary query entity may be an entity that has a contrast relationship with the primary query entity.
- a complete semantic question needs to include at least two elements in the triplet. For example, for triples (entities, relationships, entities), questions with complete semantics should include entities and relationships; for triples (entities, attributes, attribute values), questions with complete semantics should include entities and attributes.
- the terminal determines that the first query entity is missing in the first natural query sentence. Similarly, when the terminal does not recognize the entity characteristic information in the first natural query sentence, the terminal determines that the first entity characteristic information is missing in the first natural query sentence. In this case, the terminal determines that the first natural query sentence does not have complete semantics. Alternatively, the terminal confirms that the first natural query sentence does not have complete semantics when the terminal cannot clearly determine the intention of the first natural query sentence based on the identified relationship between the query entity and the query entity of the first natural query sentence and the semantics. . At this point, the question and answer process ends.
- the first natural query sentence acquired by the terminal is "What about A?".
- the terminal recognizes the query entity "A” but does not recognize the entity characteristic information.
- the terminal cannot predict the user's intention, and therefore, the terminal cannot answer the user.
- the first natural query sentence acquired by the terminal is "A's daughter?".
- the terminal recognizes the query entity "A", and the query entity's relationship "daughter".
- the terminal in combination with the semantics of the first natural query sentence, the terminal cannot predict whether the user wants to know who A's daughter is or whether he wants to know the attribute value of a certain attribute of A's daughter. Therefore, the terminal still cannot query the results for the user.
- the terminal When the terminal recognizes the query entity (such as the first query entity) and entity characteristic information (such as the first entity characteristic information) according to the first natural query sentence, the first query entity and the first entity characteristic information can clearly describe the first natural query The intention of the sentence, the terminal determines that the first natural query sentence has complete semantics. In this case, the terminal executes the following step S403.
- the query entity such as the first query entity
- entity characteristic information such as the first entity characteristic information
- the first natural query sentence acquired by the terminal is "What is the height of A?"
- the terminal recognizes the first query entity "A”
- the attribute of the first query entity is "height”. Therefore, the first query entity and the attributes of the first query entity can clearly express the intention of the first natural query sentence. Therefore, the terminal determines that the first natural query sentence has complete semantics.
- the terminal links the first query entity and the feature information of the first entity to the knowledge graph, and queries the knowledge graph for the first result.
- the terminal performs deduplication operations on the first query entity and the first entity characteristic information identified in S402 in the first and second ways (the first query entity and the first entity characteristic information are filtered separately to remove Repeated query entity and entity feature information), and link the deduplicated first query entity and first entity feature information to the knowledge graph.
- the terminal After linking the first query entity and the first entity feature information to the knowledge graph, the terminal can obtain the ID of the node corresponding to the first query entity in the knowledge graph, and obtain the edge corresponding to the first entity feature information in the knowledge graph The ID.
- the terminal may use any of the following methods to query the first result from the knowledge graph:
- Method 1 The terminal obtains the first result from the knowledge graph and returns the first result according to the first natural query sentence, the first query entity, and the characteristic information of the first entity.
- the specific process of obtaining the first result from the knowledge graph can be implemented by referring to the above S3. Go into details.
- the terminal may also obtain the first result from the knowledge graph and return the first result through the following S410-411 (refer to the following description for details).
- S404 The terminal stores the first query entity and the characteristic information of the first entity.
- the terminal may store the first query entity and the first entity characteristic information.
- the terminal may perform S404 before S403, or perform S404 after S403, or perform S403 and S404 at the same time, which is not limited in the embodiment of the present application.
- the terminal stores the first query entity "A” and the attributes of the first query entity " height”.
- the terminal stores the relationship "daughter" between the first query entity "A" and the first query entity.
- the terminal stores the first query entity "A”, and the first query The entity's relationship "daughter” and the first query entity's attribute "height".
- the terminal when storing the entity feature information in the embodiment of the present application, stores the limited condition and the entity feature information as a set.
- the natural query sentence obtained by the terminal is "What are the cars with a price greater than 300,000?".
- the terminal recognizes that the attribute of the first query entity is "price”, the attribute value of the first query entity is "300,000”, and the attribute value of the first query entity also has a limiting condition "greater than”. Therefore, the terminal stores the attributes of the first query entity, the attribute values of the first query entity, and the limiting conditions of the attribute values of the first query entity as a set, that is, "price", "greater than” and "300,000” are stored as a set .
- the terminal After obtaining the first result, the terminal displays the first result.
- the terminal may only display the first result. For example, when the first natural query sentence is "What is the height of A", after the terminal finds the first result from the knowledge graph according to the first natural query sentence, the terminal directly displays "180cm" to the user.
- the terminal can also convert the first result into a sentence with complete semantics corresponding to the first natural query sentence according to the stored query entity, the entity characteristic information, and the restriction conditions of the entity characteristic information, and display the sentence.
- the terminal displays the sentence “A’s height is 180cm” corresponding to the first result of the first natural query sentence “A’s height is 180cm” on the display.
- the terminal displays the sentence “A’s height is 180cm” corresponding to the first result of the first natural query sentence “A’s height is 180cm” on the display.
- the terminal uses the stored first query entity and the first entity characteristics Information, and the limiting conditions of the first entity feature information, the first result is transformed into a sentence with complete semantics and corresponding to the first natural query sentence: "Cars greater than 300,000 have xx-type cars, yy-type cars", and display "There are xx-type cars and yy-type cars for cars larger than 300,000."
- the terminal may also play the first result or a sentence corresponding to the first result in a voice form.
- the terminal may play the first result or the sentence corresponding to the first result to the user through the speaker.
- the terminal can also display the first result or the sentence corresponding to the first result in text form on the display interface while playing the first result or the sentence corresponding to the first result to the user through the speaker, as shown in (c) in Figure 6 Show.
- the embodiment of the application does not limit this.
- the specific process of obtaining the second natural query sentence by the terminal is similar to the process of obtaining the first natural query sentence by the terminal in S401, and will not be described in detail here.
- the terminal recognizes the query entity and entity characteristic information of the second natural query sentence, and determines whether the second natural query sentence has complete semantics according to the recognition result.
- the process of the terminal identifying the query entity and entity feature information of the second natural query sentence, and judging whether the second natural query sentence has complete semantics according to the recognition result, can refer to the description of S402 above, which will not be repeated here.
- the terminal determines that the second natural query sentence has complete semantics, the terminal refers to the above-mentioned methods of S403-S405 to find the result of the second natural query sentence from the knowledge graph.
- the terminal executes the following S408.
- S408 The terminal determines the second query entity of the second natural query sentence according to the first query entity, and determines the second entity characteristic information of the second natural query sentence according to the first entity characteristic information.
- the terminal determines the second query entity of the second natural query sentence according to the first query entity, and determines the second entity feature of the second natural query sentence according to the first entity feature information information.
- the terminal determines the second query entity according to the first query entity. Specifically, the terminal uses the first query entity as the second query entity.
- the terminal determines the second entity characteristic information according to the first entity characteristic information. Specifically, the terminal uses the relationship of the first query entity as the second entity feature information.
- the terminal recognizes that the first query entity is "A”, and the relationship of the first query entity is "daughter”. At this time, the first natural query The characteristic information of the sentence is a relationship. Then, if the second natural query sentence is "then who is his sister?", at this time, the terminal recognizes that the relationship of the second query entity is "sister", but the entity is not recognized. Therefore, the terminal regards the first query entity "A" as the second query entity, and the relationship between the second query entity and the second query entity constitutes a complete semantic question: who is A's sister.
- the terminal recognizes that the second query entity is "B", but cannot recognize the characteristic information. Therefore, the terminal regards the relationship "daughter" of the first query entity as the relationship of the second query entity, and the relationship between the second query entity and the second query entity constitutes a complete semantic question: who is B's daughter.
- the terminal determines the second query entity according to the first query entity. Specifically, the terminal uses the first query entity as the second query entity.
- the terminal determines the second entity feature information according to the first entity feature information. Specifically, the terminal uses the attribute of the first query entity as the second entity feature information.
- the terminal recognizes that the first query entity is "A”, and the attribute of the first query entity is "height". At this time, the first natural query The characteristic information of the sentence is the attribute. Then, if the second natural query sentence is "what age?", at this time, the terminal recognizes that the attribute of the second query entity is "age", but the entity cannot be recognized. Therefore, the terminal regards the first query entity "A” as the second query entity, and the attributes of the second query entity and the second query entity constitute a complete semantic question: what is the age of A. If the second natural query sentence is "What about B?", at this time, the terminal recognizes that the second query entity is "B", but cannot recognize the characteristic information. Therefore, the terminal takes the attribute "height" of the first query entity as the attribute of the second query entity, and the attributes of the second query entity and the second query entity constitute a complete semantic question: what is the height of B.
- the terminal determines the first query entity according to the first query entity. 2.
- Query entities Specifically, the terminal uses the first query entity as the second query entity.
- the terminal determines the second entity feature information according to the first entity feature information. Specifically, the terminal uses the attribute of the first query entity and the relationship between the first query entity as the second entity feature information.
- the terminal uses the attribute of the first query entity as the attribute of the second entity characteristic information. It should be noted that the second natural query sentence does not include the attributes of the second query entity and the second query entity at the same time.
- the terminal recognizes that the first query entity is "A”, the relationship of the first query entity is "daughter”, and the first query entity's relationship is "Daughter".
- the attribute is "height”.
- the terminal recognizes that the second query entity is "B", but cannot recognize the relationship or attribute. Therefore, the terminal uses the relationship "daughter" of the first query entity as the relationship of the second query entity, and uses the attribute "height" of the first query entity as the attribute of the second query entity. In this way, the second query entity, the relationship between the second query entity, and the attributes of the second query entity constitute a complete semantic question: what is the height of B's daughter.
- the terminal recognizes that the relationship of the second query entity is "sister", but the entity and attribute are not recognized. Therefore, the terminal uses the first query entity "A" as the second query entity, and uses the attribute "height" of the first query entity as the attribute of the second query entity. In this way, the second query entity, the relationship between the second query entity, and the attributes of the second query entity constitute a complete semantic question: what is the height of A's sister.
- the terminal recognizes that the attribute of the second query entity is "age", but the entity and relationship are not recognized. In this way, the terminal uses the first query entity "A" as the second query entity, and uses the relationship "daughter" of the first query entity as the relationship of the second query entity. In this way, the second query entity, the relationship between the second query entity, and the attributes of the second query entity constitute a complete semantic question: how old is the daughter of A.
- the terminal recognizes that the second query entity is "B", and the relationship of the second query entity is "daughter", but the attribute is not recognized. In this way, the terminal uses the attribute "height" of the first query entity as the attribute of the second query entity. In this way, the second query entity, the relationship between the second query entity, and the attributes of the second query entity constitute a complete semantic question: what is the height of B's daughter.
- the terminal regards the first main query entity as the second The main query entity.
- the terminal regards the first query entity as the second query entity.
- the terminal uses the first entity feature information as the second entity feature information. Wherein, the second natural query sentence does not include the second query entity and the attributes of the second query entity at the same time.
- the terminal recognizes that the first query entity is "A” and "B", and the attribute of the first query entity is "height". Among them, "A” is the first main query entity, and "B” is the first query entity. Then, if the second natural query sentence is "what age”, at this time, the terminal recognizes the attribute "age” of the second query entity, but cannot recognize the second query entity. Therefore, the terminal regards the first primary query entity "A” as the second primary query entity, and the first query entity "B” as the second query entity, so that the second primary query entity, the second query entity, and The attributes of the second query entity constitute a complete semantic question: who is older than A or B.
- the terminal After determining the second query entity and the second entity feature information, the terminal links the second query entity to the node in the knowledge graph according to the determined second query entity and the second entity feature information, and then combines the second entity feature information Link to the edge in the knowledge graph.
- the terminal For the process of the terminal linking the second query entity and the feature information of the second entity to the knowledge graph, reference may be made to the description of S402 above, which will not be described in detail here.
- S409 The terminal determines the question type of the second natural query sentence, and determines the knowledge graph query sentence of the second natural query sentence according to the second natural query sentence, the second query entity, and the characteristic information of the second entity.
- the terminal inputs the second natural query sentence with improved semantics into the preset second preset model to determine the question type of the second natural query sentence.
- the second preset model is obtained by the developer through training based on a large amount of question data in advance, and is used to determine the question type of the natural query sentence.
- the format of the second preset model may be (question, question type).
- the question type can be single-hop search for attributes, single-hop search for relationships, two-hop search for attributes, and two-hop search for attributes of entities. among them:
- Single-hop search for attributes means that the attributes can be determined by one jump in the knowledge graph.
- Single-hop search for relationships means that the relationship entity can be determined by one jump in the knowledge graph;
- two-hop search attributes means that after the relationship entity is determined by one jump in the knowledge graph, jump again to find the attributes of the relationship person;
- Jumping to find the attribute relationship of an entity means that in the knowledge graph, the attribute of entity A is determined by jumping once, and the attribute of entity B is determined by jumping again, and then the two attribute values are compared to obtain the result.
- the question type is "single-hop search attributes". In other words, one jump in the knowledge graph can determine the attributes of entity A.
- the question type is "single-hop search relationship". In other words, one jump in the knowledge graph can determine the relationship person of entity A.
- the question type is "2 jump query to find attributes". That is to say, in the knowledge graph, after jumping once to determine the related person of entity A, jump again to determine the attribute of the related person.
- the question type is "2 hops to find the attribute relationship of the entity". That is to say, in the knowledge graph, jump once to determine the attribute of entity A, jump again to determine the attribute of entity B, and then compare the two attribute values to obtain the query result.
- the terminal can determine the knowledge graph query sentence of the second natural query sentence after perfecting the semantics in an existing manner. For details, please refer to the description of S3, which will not be repeated here.
- the terminal may also determine the knowledge graph query sentence (corresponding to the target query sentence in the embodiment of the present application) of the second natural query sentence after perfecting the semantics in the following manner.
- the knowledge graph query sentence of the second natural query sentence described in the embodiment of the present application refers to the knowledge graph query sentence of the second natural query sentence after the semantics are improved.
- the terminal first determines the question template of the second natural query sentence according to the second natural query sentence after the semantics are refined, the second query entity, and the second entity characteristic information.
- the second natural query sentence after perfecting semantics is: How high is A?
- the entity acquired by the terminal according to the method described in S402 is "A”, and the attribute is "height". Therefore, the terminal can abstract the second natural query sentence as a question template " ⁇ person entity ⁇ has ⁇ height attribute ⁇ ".
- the terminal traverses the question templates in the question template library, and calculates the similarity between each question template in the question template library and the question template of the second natural query sentence. Further, the terminal determines the question template with the greatest similarity to the question template of the second natural query sentence in the question template library as the target question template.
- the problem template library is preset by the developer.
- the question template library includes m question templates and m knowledge graph query statements, m question templates correspond to m knowledge graph query statements, and each query statement in the m knowledge graph query statements uniquely corresponds to a question template.
- the format of the question template library can be (question template, query statement).
- the knowledge graph query statement is composed of query language and template parts.
- the knowledge graph query sentence for querying height is: select y from database where ⁇ person entity ⁇ x>and ⁇ height attribute ⁇ y>, where select y from database where ⁇ x>and ⁇ y> is the language part, ⁇ Character entity ⁇ and ⁇ height attribute ⁇ are the template parts.
- the terminal determines the knowledge graph query sentence of the second natural query sentence in the question template library.
- the terminal determines the target question template in the question template library as " ⁇ person entity ⁇ has ⁇ height attribute ⁇ ". Therefore, the query sentence corresponding to the terminal determining the target question template is: select y from database where ⁇ person entity ⁇ x>and ⁇ height attribute ⁇ y>.
- S410 The terminal queries the knowledge graph for the second result according to the second query entity, the feature information of the second entity, the knowledge graph query statement of the second natural query statement, and the question type of the second natural query statement.
- the terminal replaces the above-mentioned knowledge graph query with the ID of the node corresponding to the second query entity in the knowledge graph and the ID of the edge corresponding to the feature information of the second entity in the knowledge graph.
- the template part of the statement The terminal queries the knowledge graph for the second result according to the knowledge graph query sentence after replacing the ID, and returns the second result.
- the second natural query sentence after perfecting the semantics is "How tall is A's height?".
- the second query entity is "A”
- the ID of the node corresponding to the second query entity in the knowledge graph is "ID(A)”.
- the attribute of the second query entity is "height”
- the ID of the edge corresponding to the attribute of the second query entity in the knowledge graph is "ID (height)”.
- the query sentence of the knowledge graph acquired by the terminal is: select y from database where ⁇ person entity ⁇ x>and ⁇ height attribute ⁇ y>.
- the question type of the second natural query sentence is "single-hop search attribute".
- the terminal uses the ID of the node corresponding to the second query entity in the knowledge graph and the corresponding edge of the attribute of the second query entity in the knowledge graph according to the question type of the second natural query sentence.
- ID replaces the template part in the query statement of the above knowledge graph.
- the above-mentioned knowledge graph query sentence becomes: select ID (height) from database where ID(A).
- the terminal searches for the result from the knowledge graph according to the knowledge graph query sentence that has been replaced by the ID value, and returns the second result.
- the second natural query sentence after perfecting the semantics is "How tall is the height of A's daughter?".
- the second query entity is "A”
- the ID of the node corresponding to the second query entity in the knowledge graph is "ID(A)”.
- the relationship of the second query entity is "daughter”
- the ID of the edge corresponding to the relationship of the second query entity in the knowledge graph is "ID (daughter)”.
- the attribute of the second query entity is "height”
- the ID of the edge corresponding to the attribute of the second query entity in the knowledge graph is "ID (height)”.
- the query sentence of the knowledge graph acquired by the terminal is: select y from database where ⁇ person entity ⁇ x>and ⁇ height attribute ⁇ y>.
- the question type of the second natural query sentence is "2-hop search attribute".
- the terminal uses the ID of the node corresponding to the second query entity in the knowledge graph and the ID of the edge corresponding to the second query entity in the knowledge graph.
- the formed function and the ID of the edge corresponding to the attribute of the second query entity in the knowledge graph replace the template part in the above-mentioned knowledge graph query sentence.
- the above-mentioned knowledge graph query sentence becomes: select ID (height) from database where ID (X) and (ID (A), ID (daughter), ID (X)).
- ID(X)and(ID(A), ID(daughter), ID(X)) is a function determined according to the "two-hop search attribute”
- "X" represents the relationship of the second query entity "A" Person (here, daughter) entity
- ID(X) represents the ID of the node corresponding to the related person entity in the knowledge graph.
- the terminal queries the result from the knowledge graph according to the query sentence of the knowledge graph after replacing the ID, and returns the second result.
- S411 The terminal stores the second query entity and the characteristic information of the second entity.
- the terminal After the terminal determines the second query entity and the second entity characteristic information of the second natural query sentence in S408, the terminal stores the second query entity and the second entity characteristic information.
- the terminal may execute S411 while executing any step of S409-S410, and the terminal may also execute S411 after S409-S410, which is not limited in this application.
- the terminal stores the second query entity and the second entity characteristic information determined in S408 to update the first query entity and the first entity characteristic information.
- the terminal replaces the first query entity with the second query entity, and replaces the first entity feature information with the second entity feature information.
- the terminal replaces the first primary query entity with the second primary query entity, Replace the first query entity with the second query entity. If the first query entity includes the first primary query entity and the first query entity, and the second query entity includes one entity, the terminal replaces the first primary query entity with the second query entity. If the first query entity includes one entity and the second query entity includes the second primary query entity and the second query entity, the terminal replaces the first query entity with the second primary query entity.
- the terminal outputs the second result to the user.
- the terminal For a specific implementation manner, refer to the foregoing S405, which will not be described in detail here.
- the terminal when the terminal receives a natural query sentence (such as a second natural query sentence) input by the user with incomplete semantics, the terminal can combine the pre-stored query
- the entity and entity characteristic information (such as the first query entity and the first entity characteristic information in the embodiment of this application) complete the semantics of the current question.
- the terminal queries the knowledge graph based on the semantically improved questions, and outputs the query results to the user, which effectively solves the problem that the terminal cannot obtain the query results of natural query sentences that do not have complete semantics.
- the terminal deletes the stored query entity and entity characteristic information (such as the first query entity and the first entity characteristic information, or the second query entity and the second entity characteristic information). Specifically, within the first preset period of time, if the terminal does not obtain a new natural query sentence, and the storage period of the entity and characteristic information exceeds the first preset period of time, the terminal deletes the stored entity and characteristic information, or the terminal will The stored entity and feature information is invalidated. In this way, the utilization rate of the storage space of the terminal can be effectively improved, and the timeliness of the question answering system can be improved.
- the first preset duration can be set according to actual needs, which is not limited in the embodiment of the present application.
- the question and answer method based on the knowledge graph provided by the embodiment of the present application can also be used for dialogue guidance.
- the terminal can guide the user according to the user's historical questioning information and the preset guidance strategy.
- the guiding strategy is pre-set by the developer according to the needs of the field, or it can be customized by the user.
- the boot strategy is stored in the terminal.
- FIG. 7 shows a schematic flowchart of another question and answer method based on a knowledge graph provided by an embodiment of the present application.
- the question answering method based on the knowledge graph provided by the embodiment of the present application includes the following steps:
- the terminal executes S401-S404. Specifically, in S404, the terminal uses any of the following methods to store the first query entity and the characteristic information of the first entity:
- Method a The terminal stores the first query entity and the first entity characteristic information in the first storage space, and stores the first query entity and the first entity characteristic information in the second storage space, and the first storage space is used to store the latest query The entity and the latest entity characteristic information, the second storage space is used to store the historical query entity and the historical entity characteristic information determined by the terminal.
- the terminal stores the first query entity and the first entity characteristic information in a third storage space, the third storage space is used to store the query entity and entity characteristic information that the terminal has determined, and to mark the latest query entity and entity characteristic information .
- the terminal uses the method a in S404 to store the first query entity and the first entity characteristic information, the terminal stores the second query entity and the second entity characteristic information in the second storage space. At the same time, the terminal updates the first query entity in the first storage space to the second query entity, and updates the first entity feature information in the first storage space to the second entity feature information.
- the update process refer to the above S408. I will not repeat it here.
- the terminal uses the method b in S404 to store the first query entity and the first entity characteristic information, the terminal stores the second query entity and the second entity characteristic information in the third storage space, and marks the second query entity as the latest query Entity, and marking the second entity feature information as the latest entity feature information.
- the question and answer method based on the knowledge graph provided by the embodiment of the present application further includes S701:
- the terminal generates a guide language.
- the terminal generates a guide language according to the stored first query entity, first query entity information, second query entity, second query entity information, and guidance strategy.
- the first query entity, the first query entity information, the second query entity, and the second query entity information may reflect the intention of the user's question and the question that the user is interested in. Therefore, after the first query entity, the first query entity information, the second query entity, and the second query entity information are combined with the guidance strategy, the terminal generates a guidance language to guide the user's subsequent operations.
- the terminal is a mobile phone as an example.
- the third natural query sentence "What is the height of A?” entered by the user in the question and answer input box 82 of the question and answer interface 81 of the mobile phone.
- the mobile phone determines that the third query entity is "A", and the characteristic information of the third entity is "height".
- the mobile phone queries the knowledge graph for the third result of the third natural query sentence according to the third query entity and the characteristic information of the third entity and outputs it to the user.
- the terminal combines the guidance strategy, and based on the third query entity and the third entity characteristic information of the third natural query sentence, the terminal generates the first guidance phrase "Do you still need to know the height of A's daughter?".
- the question answering method based on the knowledge graph provided in the embodiment of the present application further includes S702:
- S702 The terminal outputs the first guide language to the user.
- the terminal displays the third result and the first guideline to the user on the display interface of the mobile phone.
- the user inputs "yes” or “yes” into the mobile phone.
- the specific process please refer to S401, which will not be repeated here.
- S702 can be executed simultaneously with S412, or can be executed after S412, which is not limited in this application.
- the terminal can delete stored historical information, including information such as query entities (such as the first query entity, the second query entity), entity feature information (such as the first feature type, the second feature type), etc., thereby effectively improving Utilization of the storage space of the terminal, and improve the timeliness of the question and answer system.
- query entities such as the first query entity, the second query entity
- entity feature information such as the first feature type, the second feature type
- the terminal determines that the time from the last time the user asked the terminal to the current time exceeds a first preset time period, and within the first preset time period, the terminal does not obtain a new natural query sentence . In this case, the terminal deletes the historical information stored during the interaction with the user, or the terminal invalidates the historical information stored during the interaction with the user.
- the terminal when the terminal determines that the time length from the time of acquiring the first natural query sentence to the current time exceeds the second preset time length, the terminal deletes the historical information stored before the time length 1, or the terminal sets the time length before 1 The stored historical information is invalidated.
- the duration 1 is less than the second preset duration, and the duration 1 is the duration from time 1 to the current time. Time 1 is any time during the interaction between the terminal and the user.
- the terminal when the terminal determines that the number of stored historical information is greater than the first threshold, the terminal starts with the historical information with the earliest storage time and deletes n pieces of historical information according to the storage time of the historical information, or deletes n pieces of historical information according to the storage time of the historical information.
- the historical information of is invalidated.
- n is a positive integer greater than or equal to 1, and n is less than the first threshold.
- the first threshold can be specifically set according to actual needs, which is not limited in this application.
- the embodiments of the present application provide a question and answer method based on a knowledge graph.
- the terminal can combine the entity and feature information that has been stored in advance (such as the first query entity and the first entity feature information in the embodiment of the present application) to respond to the current question.
- the semantics of is improved.
- the terminal queries the knowledge graph according to the semantically improved questions, and outputs the result to the user.
- the existing question answering system only establishes a one-to-one relationship mapping network in the database, and the connection between the knowledge points and the knowledge points is very weak, so the answers fed back to the users are often inaccurate.
- the question and answer method based on the knowledge graph provided by the embodiment of the present application can quickly and accurately feedback answers to the user, and effectively solve the problem that the terminal cannot obtain the query result of the natural query sentence without complete semantics.
- the terminal can guide and recommend the user according to the user's historical query information and the guidance strategy, which improves the interaction experience between the user and the terminal.
- the embodiment of the present application can divide the function modules of the question and answer device based on the knowledge graph according to the above method examples.
- each function module can be divided corresponding to each function, or two or more functions can be integrated into one processing module.
- the above-mentioned integrated modules can be implemented in the form of hardware or software function modules. It should be noted that the division of modules in the embodiments of the present application is illustrative, and is only a logical function division, and there may be other division methods in actual implementation.
- FIG. 9 it is a schematic structural diagram of a question and answer device based on a knowledge graph provided by an embodiment of this application.
- the question answering device is used for tracking question answering based on the knowledge graph, and dialogue guidance, for example, for executing the method shown in FIG. 4 or FIG.
- the question answering device may include an acquisition unit 90, an identification unit 91, a determination unit 92, an inquiry unit 93, and an output unit 94.
- the acquiring unit 90 is configured to acquire a first natural query sentence, the first natural query sentence including the first query entity and the first entity characteristic information, and the first entity characteristic information includes the attribute of the first query entity or the relationship between the first query entity At least one of them.
- the query unit 93 is configured to query the knowledge graph to obtain the first result according to the first query entity and the characteristic information of the first entity.
- the output unit 94 outputs the first result inquired by the inquiry unit 93.
- the obtaining unit 90 is also used to obtain the second natural query sentence.
- the determining unit 92 is configured to determine the missing part of the second natural query sentence according to the first query entity or the characteristic information of the first entity.
- the query unit 93 is further configured to query the knowledge graph to obtain the second result according to the missing part of the second natural query sentence determined by the determining unit 92.
- the output unit 94 is also used to output the second result inquired by the inquiry unit 93.
- the acquiring unit 90 may be used to perform S401 and S406.
- the determining unit 92 may be used to execute S408.
- the query unit 93 is used to execute S403 and S410.
- the output unit 94 can be used to perform S405 and S412.
- the determining unit 92 is further configured to determine that the second natural query sentence is missing the second query entity or the second entity before determining the missing part of the second natural query sentence according to the first query entity or the characteristic information of the first entity Feature information, the feature information of the second entity includes at least one of the attribute of the second query entity or the relationship of the second query entity.
- the determining unit 92 is specifically configured to determine the second query entity according to the first query entity if the second natural query sentence lacks the second query entity.
- the determining unit 92 is further specifically configured to determine the second entity characteristic information according to the first entity characteristic information if the second natural query sentence lacks the second entity characteristic information.
- the determining unit 92 may be used to perform S408.
- the identifying unit 91 is configured to identify the query entity and entity characteristic information in the second natural query sentence according to preset rules to obtain the second query entity or the second entity characteristic information.
- the identification unit 91 may be used to perform S402 and S407.
- the determining unit 92 is specifically configured to determine that the second natural query sentence is missing the second query entity if the recognition unit 91 does not obtain the second query entity; if the recognition unit 91 does not obtain the second entity characteristic information, determine the second natural query entity The query sentence lacks the characteristic information of the second entity.
- the identifying unit 91 and the determining unit 92 may be used to perform S402 and S407.
- the recognition unit 91 is specifically configured to input the second natural query sentence into the first preset model to obtain the initial query entity or initial entity characteristic information.
- the initial query entity is obtained, the initial query entity is expanded according to the preset algorithm and the second natural query sentence; the second query entity is obtained according to the preset dictionary and the expanded initial query entity.
- the initial entity characteristic information is obtained, the initial entity characteristic information is expanded according to the preset algorithm and the second natural query sentence; the second entity characteristic information is obtained according to the dictionary and the expanded initial entity characteristic information.
- the dictionary corresponds to the knowledge graph.
- the identification unit 91 may be used to perform S402 and S407.
- the determining unit 92 is further configured to determine the question type of the second natural query sentence by using a preset question model according to the second query entity, the second entity characteristic information, and the second natural query sentence.
- the determining unit 92 may be used to execute S409.
- the determining unit 92 is further configured to determine the question template of the second natural query sentence according to the second natural query sentence and the missing part of the second natural query sentence.
- the determining unit 92 is also used to determine the target query sentence in the preset question template library.
- the question template library includes m question templates and m query statements, each of the m query statements uniquely corresponds to a question template, and m is a positive integer.
- the target query sentence corresponds to the target question template, and the target question template is: in the question template library, the template with the greatest similarity to the question template of the second natural query sentence.
- the query unit 93 is further configured to query the knowledge graph to obtain the second result according to the question type and target query sentence of the second natural query sentence determined by the determining unit 92.
- the determining unit 92 may be used to perform S409, and the query unit 93 may be used to perform S410.
- the determining unit 92 is further configured to determine the guiding sentence according to the first query entity, the characteristic information of the first entity, the missing part of the second natural query sentence, the second natural query sentence, and a preset guiding strategy. Used to guide the user's next operation.
- the output unit 94 is further configured to output the introductory sentence determined by the determining unit 92.
- the determining unit 92 may be used to perform S701
- the output unit 94 may be used to perform S702.
- the question answering device based on the knowledge graph provided by the embodiment of the present application includes but is not limited to the aforementioned units.
- the question answering device may further include a storage unit 95.
- the storage unit 95 can be used to store the program code of the question and answer device, and can also be used to store data obtained during the operation of the question and answer device, such as the first query entity, the first entity characteristic information, the second query entity, and the second query entity. Entity feature information, etc.
- the functions implemented by the acquisition unit 90 and the output unit 94 in the question and answer device based on the knowledge graph are the same as the functions of the communication device 33 in FIG.
- the functions implemented by the identification unit 91, the determination unit 92, and the query unit 93 are the same as those of the processor 31 in FIG. 3.
- the function implemented by the storage unit 95 is the same as that of the memory 32 in FIG. 3.
- the chip system includes at least one processor 101 and at least one interface circuit 102.
- the processor 101 and the interface circuit 102 may be interconnected by wires.
- the interface circuit 102 may be used to receive signals from other devices (such as the memory of a question answering device based on a knowledge graph).
- the interface circuit 102 may be used to send signals to other devices (for example, the processor 101).
- the interface circuit 102 may read an instruction stored in the memory, and send the instruction to the processor 101.
- the question-and-answer device can execute the steps in the foregoing embodiments.
- the chip system may also include other discrete devices, which are not specifically limited in the embodiment of the present application.
- Another embodiment of the present application also provides a non-volatile storage medium that stores instructions in the non-volatile storage medium.
- the question and answer device executes the above method embodiment The steps performed by the terminal in the method flow shown.
- the disclosed methods may be implemented as computer program instructions encoded on a non-volatile storage medium in a machine-readable format or encoded on other non-transitory media or articles.
- Fig. 11 schematically shows a conceptual partial view of a computer program product provided by an embodiment of the present application.
- the computer program product includes a computer program for executing a computer process on a computing device.
- the computer program product is provided using the signal bearing medium 110.
- the signal bearing medium 110 may include one or more program instructions, which, when executed by one or more processors, can provide the functions or part of the functions described above with respect to FIG. 4 or FIG. 7. Therefore, for example, referring to one or more features of S401 to S412 in FIG. 4 may be undertaken by one or more instructions associated with the signal bearing medium 110.
- the program instructions in FIG. 11 also describe example instructions.
- the signal-bearing medium 110 may include a computer-readable medium 111, such as, but not limited to, a hard disk drive, compact disk (CD), digital video compact disk (DVD), digital tape, memory, read-only storage memory (read -only memory, ROM) or random access memory (RAM), etc.
- a computer-readable medium 111 such as, but not limited to, a hard disk drive, compact disk (CD), digital video compact disk (DVD), digital tape, memory, read-only storage memory (read -only memory, ROM) or random access memory (RAM), etc.
- the signal bearing medium 110 may include a computer recordable medium 112, such as, but not limited to, memory, read/write (R/W) CD, R/W DVD, and so on.
- a computer recordable medium 112 such as, but not limited to, memory, read/write (R/W) CD, R/W DVD, and so on.
- the signal-bearing medium 110 may include a communication medium 113, such as, but not limited to, digital and/or analog communication media (eg, fiber optic cables, waveguides, wired communication links, wireless communication links, etc.).
- a communication medium 113 such as, but not limited to, digital and/or analog communication media (eg, fiber optic cables, waveguides, wired communication links, wireless communication links, etc.).
- the signal bearing medium 110 may be communicated by a wireless communication medium 113 (for example, a wireless communication medium that complies with the IEEE 802.11 standard or other transmission protocols).
- the one or more program instructions may be, for example, computer-executable instructions or logic-implemented instructions.
- a knowledge graph-based question answering device such as that described with respect to FIG. 4 or FIG. 7 may be configured to respond to one or more of the computer readable medium 111, the computer recordable medium 112, and/or the communication medium 113.
- Multiple program instructions provide various operations, functions, or actions.
- the above-mentioned embodiments it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof.
- a software program it can be implemented in the form of a computer program product in whole or in part.
- the computer program product includes one or more computer instructions.
- the computer execution instructions When the computer execution instructions are loaded and executed on the computer, the processes or functions according to the embodiments of the present application are generated in whole or in part.
- the computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
- Computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium.
- computer instructions may be transmitted from a website, computer, server, or data center through a cable (such as Coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL) or wireless (such as infrared, wireless, microwave, etc.) transmission to another website site, computer, server or data center.
- the computer-readable storage medium may be any available medium that can be accessed by a computer, or may include one or more data storage devices such as a server or a data center that can be integrated with the medium.
- the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, and a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)).
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Databases & Information Systems (AREA)
- Mathematical Physics (AREA)
- Data Mining & Analysis (AREA)
- Artificial Intelligence (AREA)
- Audiology, Speech & Language Pathology (AREA)
- Health & Medical Sciences (AREA)
- General Health & Medical Sciences (AREA)
- Evolutionary Computation (AREA)
- Computing Systems (AREA)
- Software Systems (AREA)
- Human Computer Interaction (AREA)
- Life Sciences & Earth Sciences (AREA)
- Animal Behavior & Ethology (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
一种基于知识图谱的问答方法及装置,涉及信息处理技术领域,解决了终端无法在知识图谱中查询不具备完整语义的自然查询语句的结果的问题。该问答方法包括:终端获取到包括第一查询实体和第一实体特征信息的第一自然查询语句之后,根据第一查询实体和第一实体特征信息从知识图谱中查询以获得第一结果;终端输出第一结果后,获取第二自然查询语句;终端根据第一查询实体或所述第一实体特征信息,确定第二自然查询语句缺失的部分;终端根据第二自然查询语句缺失的部分,在知识图谱中查询以获得第二结果,并输出该第二结果。
Description
本申请涉及信息处理技术领域,尤其涉及一种基于知识图谱的问答方法及装置。
终端可以利用知识图谱准确、快速地获取到用户采用自然语言提出的问题的答案。具体的,在获取到用户输入的问题后,终端将该问题转换为计算机查询语言,并根据该计算机查询语言,从知识图谱中查询信息,以获取该问题的答案。
现有技术中,当用户输入具有完整语义的问题时,终端能够根据知识图谱查找到该问题的答案。但是,若用户输入的问题语义不完整,终端则无法将该问题转换为计算机查询语言,进而无法获取该问题的答案。
发明内容
本申请提供一种基于知识图谱的问答方法及装置,有效解决了终端无法在知识图谱中查询不具备完整语义的自然查询语句的结果的问题。
为达上述目的,本申请提供如下技术方案:
第一方面,本申请提供了一种基于知识图谱的问答方法,基于知识图谱的问答装置获取包括第一查询实体和第一实体特征信息的第一自然查询语句,其中,第一实体特征信息包括第一查询实体的属性或第一查询实体的关系中的至少一个。问答装置根据第一查询实体和第一实体特征信息,在知识图谱中查询以获得第一结果,并输出该第一结果。接着,问答装置获取第二自然查询语句,并根据第一查询实体或第一实体特征信息,确定获取到的第二自然查询语句中缺失的部分。这样,问答装置根据确定出的第二自然查询语句缺失的部分,在知识图谱中查询以获得第二结果,并输出该第二结果。
可以看出,当接收到用户输入的具备不完整语义的自然查询语句(如本申请中的第二自然查询语句)时,终端能够结合本次会话中的历史查询实体和历史实体特征信息(如本申请中的第一查询实体和第一实体特征信息),对当前自然查询语句的语义进行完善。进一步的,终端根据语义完善后的自然查询语句在知识图谱中查询,并将该结果输出给用户。
相比现有技术中,现有的问答系统仅在数据库中建立一对一的关系映射网,知识点与知识点之间的联系十分薄弱,因此反馈给用户的答案往往并不准确。本申请提供的基于知识图谱的问答方法,能快速、精确的反馈答案给用户,并且有效地解决了终端无法获取不具备完整语义的自然查询语句的查询结果的问题。
结合第一方面,在一种可能的设计方式中,在获取到第一自然查询语句之后,问答装置还识别该第一自然查询语句中的第一查询实体和第一实体特征信息,并存储第一查询实体和第一实体特征信息。
问答装置存储第一查询实体和第一实体特征信息,能够在后续用户输入不具备完整语义的自然查询语句时,问答装置可以根据第一查询实体和第一实体特征信息,查询自然查询语句的结果。
结合第一方面,在另一种可能的设计方式中,在根据第一查询实体或第一实体特征信息,确定第二自然查询语句缺失的部分之前,问答装置还确定第二自然查询语句缺失第二查询实体或第二实体特征信息。其中,第二实体特征信息包括第二查询实体的属性或第二查询实体的关系中的至少一个。
具体的,若确定第二自然查询语句缺失第二查询实体,则问答装置根据第一查询实体,确定第二查询实体。若确定第二自然查询语句缺失第二实体特征信息,则问答装置根据第一实体特征信息,确定第二实体特征信息。
在确定第二自然查询语句存在缺失时,问答装置结合第一查询实体或第一实体特征信息,确定第二自然查询语句缺失的部分,这样,即可根据确定出的第二自然查询语句缺失的部分和第二自然查询语句,确定出具备完整语句的查询语句。
结合第一方面,在另一种可能的设计方式中,上述“问答装置确定第二自然查询语句缺失第二查询实体或第二实体特征信息”的方法包括:问答装置根据预设的规则,识别第二自然查询语句中的查询实体和实体特征信息,以得到第二查询实体或第二实体特征信息。
具体的,若问答装置没有得到第二查询实体,则确定第二自然查询语句缺失第二查询实体。若问答装置没有得到第二实体特征信息,则确定第二自然查询语句缺失第二实体特征信息。
结合第一方面,在另一种可能的设计方式中,上述“问答装置根据预设的规则,识别第二自然查询语句中的查询实体和实体特征信息,以得到第二查询实体或第二实体特征信息”的方法包括:问答装置将第二自然查询语句输入到第一预设模型,得到第二自然查询语句的初始查询实体或初始实体特征信息。
若得到了初始查询实体,则问答装置根据预设算法和第二自然查询语句,对该初始查询实体进行扩充。接着,问答装置根据预设的词典和扩充后的初始查询实体,得到第二查询实体。若得到了初始实体特征信息,则问答装置根据预设算法和第二自然查询语句,对该初始实体特征信息进行扩充。接着,问答装置根据词典和扩充后的初始实体特征信息,得到第二实体特征信息。这里,词典与知识图谱是对应的。
本申请中的问答装置在识别自然查询语句中的查询实体和实体特征信息时,可以先采用第一预设模型识别初始查询实体和初始实体特征信息,再根据预设算法对初始查询实体和初始实体特征信息进行扩充,之后,再结合预设的词典树,问答装置确定最终的查询实体和实体特征信息。相比现有技术中直接使用词典树识别自然查询语句中的查询实体和实体特征信息的方式,本申请识别查询实体和实体特征信息的准确度更高。
结合第一方面,在另一种可能的设计方式中,问答装置根据第二查询实体、第二实体特征信息以及第二自然查询语句,采用预设的问题模型,确定第二自然查询语句的问题类型。
本申请提供的基于知识图谱的问答方法中,问答装置通过确定自然查询语句的问 题类型,简化了现有技术中将自然查询语句转化为知识图谱查询语句的过程,提高了用户体验。
结合第一方面,在另一种可能的设计方式中,上述“问答装置根据第二自然查询语句缺失的部分,在知识图谱中查询以获得第二结果”的方法包括:问答装置先根据第二自然查询语句和第二自然查询语句缺失的部分,确定出第二自然查询语句的问题模板。接着,问答装置在预设的问题模板库中确定目标查询语句。该目标查询语句与目标问题模板是对应的,目标问题模板为问题模板库中与第二自然查询语句的问题模板的相似度最大的模板。然后,问答装置根据确定出的第二自然查询语句的问题类型和目标查询语句,在知识图谱中查询以获得第二结果。这里,问题模板库包括m(m为正整数)个问题模板以及m个查询语句,m个查询语句中的每个查询语句唯一对应一个问题模板。
问答装置通过问题模板库确定查询语句,简化了现有技术中将自然查询语句转化为知识图谱查询语句的过程,提高了用户体验。
结合第一方面,在一种另可能的设计方式中,问答装置在确定出第二查询实体和第二实体特征信息后,还存储第二查询实体和第二实体特征信息。
结合第一方面,在另一种可能的设计方式中,问答装置还根据第一查询实体、第一实体特征信息、第二自然查询语句缺失的部分、第二自然查询语句以及预设的引导策略,确定引导语句,并输出该引导语句。该引导语句用于引导用户的下一步操作。
问答装置能够根据用户历史查询信息以及引导策略对用户进行引导推荐,提高了用户与问答装置的交互体验。
第二方面,本申请提供一种基于知识图谱的问答装置。该问答装置包括:获取单元,查询单元,输出单元,确定单元。
上述获取单元,用于获取第一自然查询语句,该第一自然查询语句包括第一查询实体和第一实体特征信息,第一实体特征信息包括第一查询实体的属性或第一查询实体的关系中的至少一个。上述查询单元,用于根据第一查询实体和第一实体特征信息,在知识图谱中查询以获得第一结果。上述输出单元,输出上述查询单元查询到的所述第一结果。上述获取单元,还用于获取第二自然查询语句。上述确定单元,用于根据第一查询实体或第一实体特征信息,确定第二自然查询语句缺失的部分。上述查询单元,还用于根据上述确定单元确定出的第二自然查询语句缺失的部分,在知识图谱中查询以获得第二结果。上述输出单元,还用于输出上述查询单元查询到的第二结果。
结合第二方面,在一种可能的设计方式中,该问答装置还包括存储单元,该存储单元用于存储第一查询实体和第一实体特征信息。
结合第二方面,在一种可能的设计方式中,上述确定单元,还用于在根据所述第一查询实体或第一实体特征信息,确定第二自然查询语句缺失的部分之前,确定第二自然查询语句缺失第二查询实体或第二实体特征信息,第二实体特征信息包括第二查询实体的属性或第二查询实体的关系中的至少一个。上述确定单元,具体用于若第二自然查询语句缺失第二查询实体,则根据第一查询实体,确定第二查询实体。上述确定单元,还具体用于若第二自然查询语句缺失第二实体特征信息,则根据第一实体特征信息,确定第二实体特征信息。
结合第二方面,在一种可能的设计方式中,该问答装置还包括识别单元,该上述识别单元,用于根据预设的规则,识别第二自然查询语句中的查询实体和实体特征信息,以得到第二查询实体或第二实体特征信息。上述确定单元,具体用于若上述识别单元未得到第二查询实体,则确定第二自然查询语句缺失第二查询实体;若上述识别单元未得到第二实体特征信息,则确定第二自然查询语句缺失第二实体特征信息。
结合第二方面,在一种可能的设计方式中,上述识别单元具体用于:将第二自然查询语句输入到第一预设模型,以得到初始查询实体或初始实体特征信息;若得到初始查询实体,则根据预设算法和第二自然查询语句,对所述初始查询实体进行扩充,以及根据预设的词典和扩充后的初始查询实体,得到所述第二查询实体;若得到初始实体特征信息,则根据预设算法和第二自然查询语句,对初始实体特征信息进行扩充,以及根据词典和扩充后的初始实体特征信息,得到第二实体特征信息;其中,词典与知识图谱对应。
结合第二方面,在一种可能的设计方式中,上述确定单元,还用于根据第二查询实体、第二实体特征信息以及第二自然查询语句,采用预设的问题模型,确定第二自然查询语句的问题类型。
结合第二方面,在一种可能的设计方式中,上述确定单元,还用于根据第二自然查询语句和第二自然查询语句缺失的部分,确定第二自然查询语句的问题模板。上述确定单元,还用于在预设的问题模板库中,确定目标查询语句;问题模板库包括m个问题模板以及m个查询语句,m个查询语句中的每个查询语句唯一对应一个问题模板,m为正整数。目标查询语句与目标问题模板对应,目标问题模板为:问题模板库中与第二自然查询语句的问题模板的相似度最大的模板。上述查询单元,还用于根据上述确定单元确定出的第二自然查询语句的问题类型和目标查询语句,在知识图谱中查询以获得第二结果。
结合第二方面,在一种可能的设计方式中,上述存储单元还用于存储第二查询实体和第二实体特征信息。
结合第二方面,在一种可能的设计方式中,上述确定单元还用于根据第一查询实体、第一实体特征信息、第二自然查询语句缺失的部分、第二自然查询语句以及预设的引导策略,确定引导语句,该引导语句用于引导用户的下一步操作。上述输出单元,还用于输出上述确定单元确定出的引导语句。
第三方面,本申请提供一种基于知识图谱的问答装置,该问答装置包括:存储器和一个或多个处理器;上述存储器和处理器耦合;该存储器还用于存储计算机程序代码,该计算机程序代码包括计算机指令,当所述计算机指令被问答装置执行时,使得问答装置执行如第一方面及其任一种可能的设计方式所述的问答方法。
第四方面,本申请提供一种芯片系统,该芯片系统应用于基于知识图谱的问答装置;该芯片系统包括一个或多个接口电路和一个或多个处理器;该接口电路和处理器通过线路互联;该接口电路用于从该问答装置的存储器接收信号,并向处理器发送该信号,该信号包括存储器中存储的计算机指令;当处理器执行该计算机指令时,该问答装置执行如第一方面及其任一种可能的设计方式所述的问答方法。
第五方面,本申请提供一种非易失性存储介质,该非易失性存储介质包括计算机 指令,当该计算机指令在基于知识图谱的问答装置上运行时,使该问答装置实现如第一方面及其任一种可能的设计方式所述的问答方法。
第六方面,本申请提供一种计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行如第一方面及其任一种可能的设计方式所述的基于知识图谱的问答方法。
本申请中第二方面到第六方面及其各种实现方式的具体描述,可以参考第一方面及其各种实现方式中的详细描述;并且,第二方面到第六方面及其各种实现方式的有益效果,可以参考第一方面及其各种实现方式中的有益效果分析,此处不再赘述。
在本申请中,上述基于知识图谱的问答装置的名字对设备或功能模块本身不构成限定,在实际实现中,这些设备或功能模块可以以其他名称出现。只要各个设备或功能模块的功能和本申请类似,属于本申请权利要求及其等同技术的范围之内。
本申请的这些方面或其他方面在以下的描述中会更加简明易懂。
图1为本申请实施例中知识图谱的结构示意图一;
图2为本申请实施例中知识图谱的结构示意图二;
图3为本申请实施例提供的基于知识图谱的问答装置的硬件结构示意图;
图4为本申请实施例提供的一种基于知识图谱的问答方法的流程示意图一;
图5为本申请实施例提供的一种显示界面实例示意图一;
图6为本申请实施例提供的一种显示界面实例示意图二;
图7为本申请实施例提供的一种基于知识图谱的问答方法的流程示意图二;
图8为本申请实施例提供的一种显示界面实例示意图三;
图9为本申请实施例提供的基于知识图谱的问答装置的结构示意图;
图10为本申请实施例提供的一种芯片系统的结构示意图;
图11为本申请实施例提供的计算机程序产品的结构示意图。
在本申请实施例中,“示例性的”或者“例如”等词用于表示作例子、例证或说明。本申请实施例中被描述为“示例性的”或者“例如”的任何实施例或设计方案不应被解释为比其它实施例或设计方案更优选或更具优势。确切而言,使用“示例性的”或者“例如”等词旨在以具体方式呈现相关概念。
在本申请的实施例中,术语“第一”、“第二”仅用于描述目的,而不能理解为指示或暗示相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者更多个该特征。在本申请的描述中,除非另有说明,“多个”的含义是两个或两个以上。
为了更清楚的理解本申请实施例提供的基于知识图谱的问答方法,下面对本申请实施例涉及到的技术要素进行简单说明。
知识图谱(knowledge graph,KG)
知识图谱是结构化的语义知识库,其基本组成单位是“实体、关系、实体”三元组, 或者是“实体、属性、属性值”三元组。通常,属性值也可以理解为是一种常量实体。
知识图谱通常由结点和边组成,结点表示实体或属性值,边表示属性或关系。在知识图谱中,边将各个节点连接起来,形成网状结构。其中,每个节点对应一个唯一的身份标识(identity,ID),每条边对应一个唯一的身份标识。知识图谱可应用于知识推理、搜索、问答等相关场景,并能做精准精细化的回答。
示例性的,如图1所示,图1示出了知识图谱的基本结构。该知识图谱包括节点11、节点13和节点14,节点11和节点13通过边12连接,节点11和节点14通过边15连接。其中,节点11表示实体A,边12表示关系F,节点13表示实体B,节点14表示属性值C,边15表示属性J。节点11、边12和节点13形成“实体、关系、实体”的三元组,具体用于表示“实体A和实体B之间存在关系F”。节点11、节点14和边15形成“实体、属性、属性值”的三元组,具体用于表示“实体A的属性J的属性值为属性值C”。
本申请实施例中的实体可以为人名、地名、职业等。属性可以为身高、体重、经度、纬度等。关系可以为父子、父子、母子、配偶、地理区域所属关系等。其中,父子关系也可以包括“儿子”、“父亲”等关系。
如图2所示,实体可以是人物A(节点21)、人物C(节点22),关系可以是父女(边23),因此,由图2容易知道,人物A和人物C具有父女关系。实体还可以是人物B(节点24)、地点D(节点25),关系可以是出生地(边26),因此由图2可知,人物B出生于地点D。关系还可以是夫妻(边29),因此可知,人物A和人物B为夫妻关系。属性可以为身高(边27),属性值可以为180cm(节点28),因此由图2容易知道,人物A的身高是180cm。
问答系统(question answering system,QA)
问答系统是信息检索系统的一种高级形式。问答系统能用准确、简洁的自然语言回答用户用自然语言提出的问题。
在实际应用中,终端接收用户输入的自然语言提出的问题,并通过自然语言理解(natural language understanding,NLU)算法将用户输入的自然语言问题转化成机器查询语言。终端根据所述机器查询语言在数据库中搜索并返回结果。进一步的,终端将该结果输出给用户。
知识图谱问答系统(knowledge based question answering)
知识图谱问答系统是基于知识图谱的一种问答系统。具体的,用户输入自然语言表达的问题,由终端对问题进行语义理解,并进一步转化成知识图谱查询语句。终端根据知识图谱查询语句在知识图谱上进行查询、推理等,并返回结果。最后,终端将该结果转化成自然语言输出给用户。
基于知识图谱问答系统,终端对用户提出的问题,能够做到快速、精细、准确的回答。
通常,对于用户向终端输入的具有完整语义的问题,基于知识图谱问答系统完成的问答方法可以通过以下步骤实现:
S1、终端获取自然查询语句。
终端获取的自然查询语句是由用户通过自然语言表达的、且具备完整语义的问题。 该自然查询语句能清楚的体现用户的意图。
例如,用户向终端输入自然查询语句“A的身高是多少”。根据该自然查询语句,终端能够分析出用户的意图,即用户想要查询A的身高值。这样的话,“A的身高是多少”就是一个具备完整语义的问题。
若用户向终端输入“A呢?”,此时,用户的问题仅涉及对象A。此时,终端无法分析出用户的意图。因此,“A呢?”不具备完整的语义。
S2、终端识别自然查询语句中的查询实体和实体特征信息,并将查询实体和实体特征信息链接到知识图谱。
在获取到自然查询语句后,终端先识别出自然查询语句中的查询实体和实体特征信息。该实体特征信息为查询实体的属性和查询实体的关系中的至少一个。
具体的,在终端获取到自然查询语句后,终端将该自然查询语句输入到词典树中,得到自然查询语句的查询实体和实体特征信息。这里,词典树是终端预先根据词典构建的。示例性的,终端采用自动机的方法,根据词典构建词典树。构建词典树的词典可以是通过知识图谱导出的词典,也可以是采用生成知识图谱的数据生成词典。也就是说,词典和知识图谱是对应的。
示例性的,若自然查询语句为“A的身高是多少?”,终端将该自然查询语句输入词典树中,即可获取到查询实体“A”和查询实体的属性“身高”。若自然查询语句为“A的女儿是谁?”,终端将该自然查询语句输入词典树中,即可获取到查询实体“A”和查询实体的关系“女儿”。若自然查询语句为“A的女儿的身高是多少?”,终端将该自然查询语句输入词典树中,即可获取到查询实体“A”、查询实体的关系“女儿”以及查询实体的属性“身高”。
在识别到自然查询语句中的查询实体和实体特征信息后,终端将识别到的查询实体和实体特征信息链接到知识图谱。
具体的,终端计算识别到的查询实体和知识图谱中的每个节点之间的相似度,并将该查询实体链接到知识图谱中与所述查询实体的相似度最大的节点,相应的,终端获取该节点的标识(如ID)。此外,终端计算识别到的实体特征信息和知识图谱中的每个边之间的相似度,并将该实体特征信息链接到知识图谱中与所述实体特征信息相似度最大的边,相应的,终端获取该边的标识(如ID)。
S3、终端将自然查询语句转化成知识图谱查询语句,并根据该知识图谱查询语句在知识图谱中查询结果,以及返回该结果。
通常,知识图谱采用数据库的形式进行存储。因此,利用知识图谱查询自然查询语句时,需要先将自然查询语句转化为针对该数据库的知识图谱查询语句,进而根据该知识图谱查询语句,从知识图谱中查找结果。
例如,对于自然查询语句“A的身高是多少?”,终端将该自然查询语句转化为知识图谱查询语句“select y from database where<A x>and<身高y>”。进一步的,终端用S2获取到的查询实体在知识图谱中对应的节点的ID、以及实体特征信息在知识图谱中对应的边的ID替换知识图谱查询语句中的“A”和“身高”,并从知识图谱中查询结果。终端在知识图谱中查询到结果后,将该结果返回。
若终端根据“select ID身高from database where ID(A)”在知识图谱中查找结果, 并查找到A的属性(即身高)对应的值(即属性值)为“180cm”。随后,终端将“180cm”返回。
S4、终端输出查询结果。
进一步的,终端输出S3返回的结果。
在实际应用中,当用户向问答系统连续提问时,在询问同类问题、或相似问题的时候,用户会省略问题中的部分内容。
例如,用户首次提问问题1“A的身高是多少?”,终端查询并获取该问题1的结果1,接着,向用户输出结果1。随后,出于正常的语言习惯,用户可能接着提问问题2“B呢?”。这种情况下,用户实际想要知道的是B的身高是多少。但是,由于问题2只包含了对象B,因此终端无法识别用户的真正目的是什么,进而也就不能为用户查询到问题的结果。
基于此,本申请实施例提供一种基于知识图谱的问答方法及装置。当接收到用户输入的具备不完整语义的自然查询语句时,终端能够结合预先已经存储的实体和特征信息(如本申请实施例中的第一查询实体和第一实体特征信息),对当前问题的语义进行完善。进一步的,终端根据语义完善后的问题在知识图谱中查询,并将查询结果输出给用户,有效地解决了终端无法获取不具备完整语义的自然查询语句的查询结果的问题。
本申请实施例提供的基于知识图谱的问答方法可以通过安装在终端上的应用程序实现,如:浏览器、电子商城的智能客服、语音助手等。
上述应用程序可以是安装在设备中的嵌入式应用程序(即设备的系统应用),也可以是可下载应用程序。其中,嵌入式应用程序是作为设备(如手机)实现的一部分提供的应用程序。可下载应用程序是一个可以提供自己的因特网协议多媒体子系统(internet protocol multimedia subsystem,IMS)连接的应用程序,该可下载应用程序是可以预先安装在设备中的应用或可以由用户下载并安装在设备中的第三方应用。
本申请实施例提供的基于知识图谱的问答装置可以是终端。具体的,该终端可以是手机、平板电脑、可穿戴电子设备等便携式设备,也可以是车载设备、智能机器人等设备,还可以是个人计算机(personal computer,PC)、个人数字助理(personal digital assistant,PDA)、上网本、服务器等计算设备。
下面对基于知识图谱的问答装置的硬件结构进行说明。
参考图3,图3示出了本申请实施例中基于知识图谱的问答装置30的一种硬件结构。如图3所示,基于知识图谱的问答装置30包括处理器31、存储器32、通信器件33、总线34。处理器31、存储器32以及通信器件33之间可以通过总线34连接。
处理器31是基于知识图谱的问答装置30的控制中心,可以是一个通用中央处理单元(central processing unit,CPU),也可以是其他通用处理器等。其中,通用处理器可以是微处理器或者是任何常规的处理器等。
作为一个示例,处理器31可以包括一个或多个CPU,例如图3中所示的CPU 0和CPU 1。
存储器32可以是只读存储器(read-only memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(random access memory,RAM)或 者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(electrically erasable programmable read-only memory,EEPROM)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。
一种可能的实现方式中,存储器32可以独立于处理器31存在。存储器32可以通过总线34与处理器31相连接,用于存储数据、指令或者程序代码。处理器31调用并执行存储器32中存储的指令或程序代码时,能够实现本申请实施例提供的基于知识图谱的问答方法。
另一种可能的实现方式中,存储器32也可以和处理器31集成在一起。
通信器件33,用于基于知识图谱的问答装置30与其他设备(如客户端、服务器等)通过通信网络连接,所述通信网络可以是以太网,无线接入网(radio access network,RAN),无线局域网(wireless local area networks,WLAN)等。通信器件33具体用于接收数据或发送数据,如本申请实施例中的“获取第一自然查询语句”等。
当基于知识图谱的问答装置为计算设备(例如服务器)时,通信器件33可以是网络接口等。
当基于知识图谱的问答装置为便携式设备(例如手机)时,通信器件33可以是天线、触摸屏、麦克风、扬声器等。触摸屏具体可以包括触控板和显示屏。
其中,触控板可采集便携式设备的用户在其上或附近的触摸事件(比如用户使用手指、触控笔等任何适合的物体在触控板上或在触控板附近的操作),并将采集到的触摸信息发送给其他器件(例如处理器31)。其中,用户在触控板附近的触摸事件可以称之为悬浮触控;悬浮触控可以是指,用户无需为了选择、移动或拖动目标(例如图标等)而直接接触触控板,而只需用户位于设备附近以便执行所想要的功能。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型来实现触控板。
显示屏可用于显示由用户输入的信息或提供给用户的信息以及便携式设备的各种菜单。可以采用液晶显示屏、有机发光二极管等形式来配置显示屏。触控板可以覆盖在显示屏之上,当触控板检测到在其上或附近的触摸事件后,传送给处理器31以确定触摸事件的类型,随后处理器31可以根据触摸事件的类型在显示屏上提供相应的视觉输出。
总线34,可以是工业标准体系结构(Industry Standard Architecture,ISA)总线、外部设备互连(Peripheral Component Interconnect,PCI)总线或扩展工业标准体系结构(Extended Industry Standard Architecture,EISA)总线等。该总线可以分为地址总线、数据总线、控制总线等。为便于表示,图3中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
需要指出的是,图3中示出的结构并不构成对该基于知识图谱的问答装置的限定,除图3所示部件之外,该基于知识图谱的问答装置30可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
下面对本申请实施例提供的知识图谱的问答方法进行描述。
本申请实施例中的终端存储有知识图谱、第一预设模型、第二预设模型、词典树、以及问题模板库。
第一预设模型:用于识别自然查询语句中的实体和特征信息。开发人员通过对大量的自然语言问题进行实体和特征信息的标记,进行数据训练,从而获得第一预设模型。
第二预设模型(对应于本申请实施例中的问题模型):用于对自然查询语句进行问题分类。开发人员通过对大量自然语言问题标记问题类型,并进行数据训练,从而获得第二预设模型。
词典树:用于识别自然查询语句中的查询实体和实体特征信息。词典树的构建可以参考上述描述,此处不再详细赘述。
问题模板库:由问题模板和知识图谱查询语句构成,且问题模板和知识图谱查询语句对应。终端根据自然查询语句的模板,可以从问题模板库中确定自然查询语句对应的知识图谱查询语句。
图4示出了本申请实施例提供的基于知识图谱的问答方法的流程示意图。本申请实施例下面的描述以基于知识图谱的问答装置为终端为例进行说明。
如图4所示,该基于知识图谱的问答方法包括以下步骤:
S401、终端获取第一自然查询语句。
第一自然查询语句是由用户通过自然语言表达、且在本次会话中向终端输入的首个自然查询语句。
在一种实现方式中,若终端为便携设备(例如手机)时,用户可以在终端的问答输入框中手动输入第一自然查询语句。示例性的,如图5中(a)所示,以终端为手机为例。用户在手机触摸屏上显示的问答界面51的问答输入框中点击,调出虚拟键盘。然后,如图5中(b)所示,用户通过虚拟键盘,在问答输入框52中输入第一自然查询语句“A的身高是多少?”,并点击“确定”按钮提交第一自然查询语句。响应于该操作,如图5中(c)所示,手机获取到第一自然查询语句,并将第一自然查询语句显示在手机的显示界面上。
在另一种实现方式中,若终端为便携设备(例如手机)时,用户可以通过语音输入第一自然查询语句。如图6所示,以终端为手机为例。
一种示例为,如图6中(a)所示,用户操作手机触摸屏上显示的问答界面61上的语音输入图标62,并通过麦克风输入第一语音。用户操作手机触摸屏上显示的问答界面61上的语音输入图标62,可以是点击该图标,也可以是长按该图标,本申请对此不做限定。响应于用户的操作,手机获取到第一语音,并将第一语音以语音条的形式显示在手机的显示界面上,如图6中(b)所示。当然,显示在显示界面上的语音条也可以转化为文字显示在显示界面上。其中,手机将第一语音转化为文字的具体过程参考现有技术,本申请实施例不再详细赘述。
另一种示例为,用户通过唤醒词唤醒手机。然后,用户采用语音输入第一自然查询语句。例如,用户对着手机说出唤醒词“hello hello”,这时,手机被唤醒。随后,终端通过麦克风输入第一语音。响应于用户的操作,手机获取到第一语音,并将第一语音转化为文字后显示在手机触摸屏上的显示界面上。
在又一种实现方式中,若终端为计算设备时,终端可以通过网络接口接收来自客户端输入的第一自然查询语句。
上述描述的终端获取第一自然查询语句的方式仅为示例性说明,并不构成对本申请实施例的保护范围的限定。
S402、终端识别第一自然查询语句的查询实体和实体特征信息,并根据识别结果,判断第一自然查询语句是否具备完整的语义。
实体特征信息包括查询实体的关系和查询实体的属性中的至少一种。
终端可以采用下述至少一种方式识别第一自然查询语句中的查询实体和实体特征信息:
方式一:终端识别第一自然查询语句的查询实体和实体特征信息的过程,可以参考上述S2中识别实体和特征信息的描述,此处不再赘述。
方式二:在获取到第一自然查询语句后,终端将第一自然查询语句输入到第一预设模型,以获得第一自然查询语句的初始实体和初始特征信息(为了区别S402所述的查询实体和实体特征信息,这里称通过第一预设模型获取的实体为初始实体,通过第一预设模型识别的特征信息为初始特征信息)。然后,终端根据预设的算法和第一自然查询语句,对初始实体和初始特征信息进行字数扩充。接着,终端将扩充后的初始实体和初始特征信息输入到词典树,以获取第一自然查询语句的查询实体和实体特征信息。
上述终端根据预设的算法和第一自然查询语句,对初始实体和初始特征信息进行字数扩充的方法可以为:终端根据初始实体和初始特征信息分别在第一自然查询语句中的位置,对初始实体和初始特征信息进行字数扩充。
终端可以对初始实体和初始特征信息向左扩充,也可以对初始实体和初始特征信息向右扩充,终端还可以对初始实体和初始特征信息向左向右同时扩充。
终端对初始实体和初始特征信息扩充的字数可以是终端默认设置的,也可以由用户进行设置,本申请实施例对此不作限定。
示例性的,终端获取到第一自然查询语句“王兰兰多大年纪了?”,终端将该第一自然查询语句输入到第一预设模型,识别到第一自然查询语句的初始实体为“王兰”,初始特征信息(属性)为“年纪”。若终端预设的扩充字数为1,终端根据“王兰”在第一自然查询语句中的位置,确定对“王兰”向右扩充1个字。因此,扩充后的初始实体为“王兰兰”。
可以理解的是,第一自然查询语句中的实体可以是多个。例如,终端获取的第一自然查询语句为“A和B谁个子高?”,这种情况下,终端识别到的查询实体包括“A”和“B”。在本申请实施例中,称“A”为主查询实体,称“B”为次查询实体。
又例如,终端获取的第一自然查询语句为“北京和上海哪个面积大”,这种情况下,终端识别到的查询实体包括“北京”和“上海”。在本申请实施例中,称“北京”为主查询实体,称“上海”为次查询实体。
其中,主查询实体和次查询实体同时存在于一个自然查询语句中。示例性的,次查询实体可以是和主查询实体具有对比关系的实体。
由于一条知识的基本组成单位至少包含一个三元组,因此一个完整语义的问题至少需要包括三元组中的两元。例如,针对三元组(实体,关系,实体),具备完整语义的问题应包括实体和关系;针对三元组(实体,属性,属性值),具备完整语义的 问题应包括实体和属性。
因此,当终端没有识别到第一自然查询语句中的查询实体,终端确定第一自然查询语句中缺少第一查询实体。同理,当终端没有识别到第一自然查询语句中的实体特征信息时,终端确定第一自然查询语句中缺少第一实体特征信息。这种情况下,终端确定第一自然查询语句不具备完整的语义。或者,终端根据识别到的第一自然查询语句的查询实体和查询实体的关系,并结合语义,终端不能明确确定第一自然查询语句的意图时,终端确认第一自然查询语句不具备完整的语义。此时,问答流程结束。
例如,终端获取的第一自然查询语句为“A呢?”,此时,终端识别到查询实体“A”,没有识别到实体特征信息。这种情况下,终端无法预知用户的意图,因此,终端无法回答用户。
又例如,终端获取的第一自然查询语句为“A的女儿呢?”,此时,终端识别到查询实体“A”,查询实体的关系“女儿”。这种情况下,终端结合第一自然查询语句的语义,无法预知用户是想要知道A的女儿是谁,还是想知道A的女儿的某种属性的属性值。因此,终端依旧无法为用户查询结果。
当终端根据第一自然查询语句识别到查询实体(例如第一查询实体)和实体特征信息(例如第一实体特征信息),第一查询实体和第一实体特征信息能够清楚的描述第一自然查询语句的意图,则终端确定第一自然查询语句具备完整的语义。这种情况下,终端执行下述步骤S403。
例如,终端获取的第一自然查询语句为“A的身高是多少?”,此时,终端识别到第一查询实体“A”,第一查询实体的属性“身高”。因此,第一查询实体和第一查询实体的属性能明确的表达出第一自然查询语句的意图,因此,终端确定第一自然查询语句具备完整的语义。
S403、终端将第一查询实体和第一实体特征信息链接到知识图谱,并从知识图谱中查询第一结果。
终端将第一查询实体和第一实体特征信息链接到知识图谱的过程可以参考上述S2的描述,此处不再详细赘述。
需要说明的是,当采用S402中的方式一和方式二识别第一查询实体和第一实体特征信息时,第一查询实体中可能存在重复的查询实体,第一实体特征信息中可能存在重复的实体特征信息。这种情况下,终端对采用S402中方式一和方式二识别的第一查询实体和第一实体特征信息分别做去重操作(对第一查询实体和第一实体特征信息分别进行过滤,以去除重复的查询实体和实体特征信息),并将去重后的第一查询实体和第一实体特征信息链接到知识图谱。
将第一查询实体和第一实体特征信息链接到知识图谱后,终端能够获取到第一查询实体在知识图谱中对应的节点的ID,以及获取到第一实体特征信息在知识图谱中对应的边的ID。
进一步的,终端可以采用下述任意一种方式从知识图谱中查询第一结果:
方式一、终端根据第一自然查询语句、第一查询实体以及第一实体特征信息,从知识图谱中获取第一结果并返回第一结果的具体过程,可以具体参考上述S3实现,此处不再详细赘述。
方式二、终端还可以通过下述S410-411(具体参考下述描述),从知识图谱中获取第一结果并返回第一结果。
S404、终端存储第一查询实体和第一实体特征信息。
终端可以在S402识别出第一自然查询语句的第一查询实体和第一实体特征信息后,存储第一查询实体和第一实体特征信息。
可选的,终端可以在S403之前执行S404,也可以在S403之后执行S404,也可以同时执行S403和S404,本申请实施例对此不作限定。
示例性的,结合S402,若终端识别到的第一查询实体为“A”,第一查询实体的属性为“身高”,则终端存储第一查询实体“A”和第一查询实体的属性“身高”。
若终端识别到的第一查询实体为“A”,第一查询实体的关系为“女儿”,则终端存储第一查询实体“A”和第一查询实体的关系“女儿”。
若终端识别到的第一查询实体为“A”,第一查询实体的关系为“女儿”,第一查询实体的属性为“身高”,则终端存储第一查询实体“A”,第一查询实体的关系“女儿”以及第一查询实体的属性“身高”。
当实体特征信息有限定条件时,本申请实施例在存储实体特征信息时,终端将限定条件和实体特征信息存储为一个集合。
例如,终端获取的自然查询语句为“价格大于30万的车有哪些?”。其中,终端识别到第一查询实体的属性为“价格”,第一查询实体的属性值为“30万”,并且,第一查询实体的属性值还存在限定条件“大于”。因此,终端将第一查询实体的属性、第一查询实体的属性值,以及第一查询实体的属性值的限定条件存储为一个集合,即“价格”“大于”“30万”存储为一个集合。
S405、终端输出第一结果。
终端在获取到第一结果后,显示该第一结果。
可选的,终端可以仅显示第一结果。例如,当第一自然查询语句为“A的身高是多少”,终端根据第一自然查询语句从知识图谱中查询到第一结果后,终端直接向用户显示“180cm”。
终端还可以根据存储的查询实体、实体特征信息,以及实体特征信息的限定条件,将第一结果转化为具备完整语义的、与第一自然查询语句对应的语句,并显示该语句。
例如,参考图5,如图5中(d)所示,终端(手机)将第一自然查询语句“A的身高是多少”的第一结果对应的语句“A的身高是180cm”显示在显示界面上。
又例如,当第一自然查询语句为“大于30万的车有哪些”,终端根据第一自然语句从知识图谱中查询到第一结果后,终端根据存储的第一查询实体、第一实体特征信息,以及第一实体特征信息的限定条件,将第一结果转化为具备完整语义的、与第一自然查询语句对应的语句“大于30万的车有xx型车,yy型车”,并显示“大于30万的车有xx型车,yy型车”。
此外,终端在获取到第一结果后,还可以以语音形式播放第一结果或第一结果对应的语句。
具体的,终端可以通过扬声器向用户播放第一结果或第一结果对应的语句。终端还可以在通过扬声器向用户播放第一结果或第一结果对应的语句的同时,在显示界面 上以文字形式展示第一结果或第一结果对应的语句,如图6中的(c)所示。本申请实施例对此不作限定。
以上仅是对终端输出第一结果作示例性说明,并不构成对本申请实施例的限定。
S406、在输出第一结果后,终端获取第二自然查询语句。
终端获取第二自然查询语句的具体过程与终端在S401获取第一自然查询语句的过程类似,此处不再详细赘述。
S407、终端识别第二自然查询语句的查询实体和实体特征信息,并根据识别结果,判断第二自然查询语句是否具备完整的语义。
终端识别第二自然查询语句的查询实体和实体特征信息,并根据识别结果,判断第二自然查询语句是否具备完整的语义的过程,可以参考上述S402的描述,此处不再赘述。
当终端确定第二自然查询语句具备完整的语义,终端参考上述S403-S405的方法,从知识图谱中查找第二自然查询语句的结果。
当终端确定第二自然查询语句不具备完整的语义,终端执行下述S408。
S408、终端根据第一查询实体确定第二自然查询语句的第二查询实体,以及根据第一实体特征信息确定第二自然查询语句的第二实体特征信息。
终端确定第二自然查询语句不具备完整的语义后,终端根据第一查询实体确定第二自然查询语句的第二查询实体,以及根据第一实体特征信息确定第二自然查询语句的第二实体特征信息。
在一种情况下,若第一实体特征信息为第一查询实体的关系,此时,当第二自然查询语句不包括第二查询实体时,终端根据第一查询实体确定第二查询实体。具体的,终端将第一查询实体作为第二查询实体。当第二自然查询语句不包括第二实体特征信息时,终端根据第一实体特征信息确定第二实体特征信息。具体的,终端将第一查询实体的关系作为第二实体特征信息。
示例性的,若第一自然查询语句为“A的女儿是谁?”,终端识别到第一查询实体为“A”,第一查询实体的关系为“女儿”,此时,第一自然查询语句的特征信息为关系。然后,若第二自然查询语句为“那他妹妹是谁?”,这时,终端识别到第二查询实体的关系为“妹妹”,而识别不到实体。因此,终端将第一查询实体“A”作为第二查询实体,第二查询实体与第二查询实体的关系构成一个完整语义的问题:A的妹妹是谁。若第二自然查询语句为“那B呢?”,这时,终端识别到第二查询实体为“B”,而识别不到特征信息。因此,终端将第一查询实体的关系“女儿”作为第二查询实体的关系,第二查询实体与第二查询实体的关系构成一个完整语义的问题:B的女儿是谁。
在另一种情况下,若第一实体特征信息为第一查询实体的属性,此时,当第二自然查询语句不包括实体时,终端根据第一查询实体确定第二查询实体。具体的,终端将第一查询实体作为第二查询实体。当第二自然查询语句不包括特征信息时,终端根据第一实体特征信息确定第二实体特征信息。具体的,终端将第一查询实体的属性作为第二实体特征信息。
示例性的,若第一自然查询语句为“A的身高是多少?”,终端识别到第一查询实体为“A”,第一查询实体的属性为“身高”,此时,第一自然查询语句的特征信息为属性。 然后,若第二自然查询语句为“那年纪呢?”,这时,终端识别到第二查询实体的属性为“年纪”,而识别不到实体。因此,终端将第一查询实体“A”作为第二查询实体,第二查询实体与第二查询实体的属性构成一个完整语义的问题:A的年纪是多少。若第二自然查询语句为“那B呢?”,这时,终端识别到第二查询实体为“B”,而识别不到特征信息。因此,终端将第一查询实体的属性“身高”作为第二查询实体的属性,第二查询实体与第二查询实体的属性构成一个完整语义的问题:B的身高是多少。
在第三种情况下,若第一实体特征信息包括第一查询实体的属性和第一查询实体的关系,此时,当第二自然查询语句不包括实体时,终端根据第一查询实体确定第二查询实体。具体的,终端将第一查询实体作为第二查询实体。当第二自然查询语句不包括特征信息时,终端根据第一实体特征信息确定第二实体特征信息。具体的,终端将第一查询实体的属性和第一查询实体的关系作为第二实体特征信息。当第二自然查询语句不包括特征信息中的关系和属性中的一个时,例如,第二自然查询语句不包括属性,则终端将第一查询实体的属性作为第二实体特征信息的属性。需要说明的是,第二自然查询语句不同时包括第二查询实体和第二查询实体的属性。
示例性的,若第一自然查询语句为“A的女儿的身高是多少?”,终端识别到第一查询实体为“A”,第一查询实体的关系为“女儿”,第一查询实体的属性为“身高”。
然后,若第二自然查询语句为“B呢?”,这时,终端识别到第二查询实体为“B”,而识别不到关系或属性。因此,终端将第一查询实体的关系“女儿”作为第二查询实体的关系,将第一查询实体的属性“身高”作为第二查询实体的属性。这样,第二查询实体、第二查询实体的关系以及第二查询实体的属性构成一个完整语义的问题:B的女儿的身高是多少。
或者,若第二自然查询语句为“那他妹妹呢?”,这时,终端识别到第二查询实体的关系为“妹妹”,而识别不到实体和属性。因此,终端将第一查询实体“A”作为第二查询实体,将第一查询实体的属性“身高”作为第二查询实体的属性。这样,第二查询实体、第二查询实体的关系以及第二查询实体的属性构成一个完整语义的问题:A的妹妹的身高是多少。
又或者,若第二自然查询语句为“那年纪呢?”,这时,终端识别到第二查询实体的属性为“年纪”,而识别不到实体和关系。这样,终端将第一查询实体“A”作为第二查询实体,将第一查询实体的关系“女儿”作为第二查询实体的关系。这样,第二查询实体、第二查询实体的关系以及第二查询实体的属性构成一个完整语义的问题:A的女儿的年纪有多大。
又或者,若第二自然查询语句为“那B的女儿呢?”这时,终端识别到第二查询实体为“B”,第二查询实体的关系为“女儿”,而识别不到属性。这样,终端将第一查询实体的属性“身高”作为第二查询实体的属性。这样,第二查询实体、第二查询实体的关系以及第二查询实体的属性构成一个完整语义的问题:B的女儿的身高是多少。
第四种情况下,若第一查询实体包括第一主查询实体和第一次查询实体,此时,当第二自然查询语句不包括主查询实体时,终端将第一主查询实体作为第二主查询实体。当第二自然查询语句不包括次查询实体时,终端将第一次查询实体作为第二次查询实体。当第二自然查询语句不包括特征信息时,终端将第一实体特征信息作为第二 实体特征信息。其中,第二自然查询语句不同时包括第二查询实体和第二查询实体的属性。
示例性的,若第一自然查询语句为“A和B谁个子高”,终端识别到第一查询实体为“A”和“B”,第一查询实体的属性为“身高”。其中,“A”为第一主查询实体,“B”为第一次查询实体。然后,若第二自然查询语句为“那年纪呢”,这时,终端识别到第二查询实体的属性“年纪”,而识别不到第二查询实体。因此,终端将第一主查询实体“A”作为第二主查询实体,将第一次查询实体“B”作为第二次查询实体,这样,第二主查询实体、第二次查询实体、以及第二查询实体的属性构成一个完整语义的问题:A和B谁的年纪大。
在确定出第二查询实体和第二实体特征信息后,终端根据确定出的第二查询实体和第二实体特征信息,将第二查询实体链接到知识图谱中的节点,将第二实体特征信息链接到知识图谱中的边。终端将第二查询实体和第二实体特征信息链接到知识图谱的过程可以参考上述S402的描述,此处不再详细赘述。
S409、终端确定第二自然查询语句的问题类型,以及根据第二自然查询语句、第二查询实体以及第二实体特征信息,确定第二自然查询语句的知识图谱查询语句。
具体的,终端将完善语义后的第二自然查询语句输入到预置的第二预设模型,以确定第二自然查询语句的问题类型。
其中,第二预设模型为开发人员预先根据大量问题数据训练得到,用于确定自然查询语句的问题类型。示例性的,第二预设模型的格式可以为(问题,问题类型)。
问题类型可以是单跳查找属性、单跳查找关系、二跳查询找属性、二跳查找实体的属性关系等。其中:
单跳查找属性是指在知识图谱中跳转一次即可确定出属性。单跳查找关系是指在知识图谱中跳转一次即可确定出关系实体;二跳查找属性是指在知识图谱中,跳转一次确定出关系实体后,再次跳转查找关系人物的属性;二跳查找实体的属性关系是指在知识图谱中,跳转一次确定出实体A的属性,再次跳转确定出实体B的属性,然后再将两个属性值作比较以得到结果。
示例性的,若完善语义后的第二自然查询语句为“A的身高是多少?”,则问题类型为“单跳查找属性”。也就是说,在知识图谱中跳转一次即可确定出实体A的属性。
若第二然查询语句为“A的女儿是谁?”,则问题类型为“单跳查找关系”。也就是说,在知识图谱中跳转一次即可确定出实体A的关系人物。
若第二自然查询语句为“A的女儿的身高是多少?”,则问题类型为“2跳查询找属性”。也就是说,在知识图谱中,跳转一次确定出实体A的关系人物后,再次跳转确定关系人物的属性。
若第二自然查询语句为“A和B谁年纪大?”,则问题类型为“2跳查找实体的属性关系”。也就是说,在知识图谱中,跳转一次确定出实体A的属性,再次跳转确定出实体B的属性,然后再将两个属性值作比较,以得到查询结果。
此外,终端可以采用现有的方式确定完善语义后的第二自然查询语句的知识图谱查询语句,具体可以参考S3的描述,此处不再赘述。
终端也可以通过下述方式确定完善语义后的第二自然查询语句的知识图谱查询语 句(对应本申请实施例中的目标查询语句)。
需要说明的是,本申请实施例中描述的第二自然查询语句的知识图谱查询语句是指,完善语义后的第二自然查询语句的知识图谱查询语句。
具体的,终端先根据完善语义后的第二自然查询语句、第二查询实体以及第二实体特征信息,确定第二自然查询语句的问题模板。
示例性的,完善语义后的第二自然查询语句为:A有多高?终端根据S402所述的方法获取的实体为“A”,属性为“身高”。因此,终端可以将第二自然查询语句抽象为问题模板“{人物实体}有{身高属性}”。
随后,终端遍历问题模板库中的问题模板,计算问题模板库中的每个问题模板和第二自然查询语句的问题模板之间的相似度。进一步的,终端将问题模板库中,与第二自然查询语句的问题模板之间的相似度最大的问题模板确定为目标问题模板。
在本申请实施例中,问题模板库是开发人员预设的。问题模板库中包括m个问题模板和m个知识图谱查询语句,m个问题模板和m个知识图谱查询语句对应,m个知识图谱查询语句中的每个查询语句唯一对应一个问题模板。问题模板库的格式可以为(问题模板,查询语句)。其中,知识图谱查询语句由查询语言和模板部分构成。例如,查询身高的知识图谱查询语句为:select y from database where<{人物实体}x>and<{身高属性}y>,其中,select y from database where<x>and<y>为语言部分,{人物实体}和{身高属性}为模板部分。
终端根据问题模板和知识图谱查询语句的对应关系、以及第二自然查询语句的目标问题模板,终端在问题模板库中确定第二自然查询语句的知识图谱查询语句。
示例性的,终端根据第二自然查询语句的问题模板,在问题模板库中确定的目标问题模板为“{人物实体}有{身高属性}”。因此,终端确定目标问题模板对应的查询语句为:select y from database where<{人物实体}x>and<{身高属性}y>。
S410、终端根据第二查询实体,第二实体特征信息、第二自然查询语句的知识图谱查询语句、以及第二自然查询语句的问题类型从知识图谱中查询第二结果。
具体的,终端根据第二自然查询语句的问题类型,用第二查询实体在知识图谱中对应的节点的ID、以及第二实体特征信息在知识图谱中对应的边的ID,替换上述知识图谱查询语句中的模板部分。终端根据替换ID后的知识图谱查询语句,从知识图谱中查询第二结果,并将第二结果返回。
例如,若完善语义后的第二自然查询语句为“A的身高有多高?”。其中,第二查询实体为“A”,第二查询实体在知识图谱中对应的节点的ID为“ID(A)”。第二查询实体的属性为“身高”,第二查询实体的属性在知识图谱中对应的边的ID为“ID(身高)”。终端获取的知识图谱查询语句为:select y from database where<{人物实体}x>and<{身高属性}y>。并且,第二自然查询语句的问题类型为“单跳查找属性”。
因此,终端根据第二自然查询语句的问题类型“单跳查找属性”,终端用第二查询实体在知识图谱中对应的节点的ID、以及第二查询实体的属性在知识图谱中对应的边的ID替换上述知识图谱查询语句中的模板部分。这样的话,上述知识图谱查询语句变为:select ID(身高)from database where ID(A)。终端根据进行了ID值替换的知识图谱查询语句,从知识图谱中查询结果,并返回第二结果。
又例如,完善语义后的第二自然查询语句为“A的女儿的身高有多高?”。其中,第二查询实体为“A”,第二查询实体在知识图谱中对应的节点的ID为“ID(A)”。第二查询实体的关系为“女儿”,第二查询实体的关系在知识图谱中对应的边的ID为“ID(女儿)”。第二查询实体的属性为“身高”,第二查询实体的属性在知识图谱中对应的边的ID为“ID(身高)”。终端获取的知识图谱查询语句为:select y from database where<{人物实体}x>and<{身高属性}y>。并且,第二自然查询语句的问题类型为“2跳查找属性”。
因此,终端根据第二自然查询语句的问题类型“二跳查找属性”,终端用第二查询实体在知识图谱中对应的节点的ID和第二查询实体的关系在知识图谱中对应的边的ID构成的函数、以及第二查询实体的属性在知识图谱中对应的边的ID替换上述知识图谱查询语句中的模板部分。
这样的话,上述知识图谱查询语句变为:select ID(身高)from database where ID(X)and(ID(A),ID(女儿),ID(X))。其中,“ID(X)and(ID(A),ID(女儿),ID(X))”为根据“二跳查找属性”确定的函数,“X”表示第二查询实体“A”的关系人物(这里为女儿)实体,ID(X)表示关系人物实体在知识图谱中对应的节点的ID。
最后,终端根据替换ID后的知识图谱查询语句,从知识图谱中查询结果,并返回第二结果。
S411、终端存储第二查询实体和第二实体特征信息。
终端可以在S408确定出第二自然查询语句的第二查询实体和第二实体特征信息后,终端将第二查询实体和第二实体特征信息进行存储。
可选的,终端可以在S409-S410中任一步骤执行的同时执行S411,终端也可以在S409-S410之后执行S411,本申请对此不作限定。
终端将S408确定的第二查询实体和第二实体特征信息进行存储,用以更新第一查询实体和第一实体特征信息。
具体的,终端用第二查询实体替换第一查询实体,用第二实体特征信息替换第一实体特征信息。
若第一查询实体包括第一主查询实体和第一次查询实体,第二查询实体包括第二主查询实体和第二次查询实体,则终端用第二主查询实体替换第一主查询实体,用第二次查询实体替换第一次查询实体。若第一查询实体包括第一主查询实体和第一次查询实体,第二查询实体包括一个实体,则终端用第二查询实体替换第一主查询实体。若第一查询实体包括一个实体,第二查询实体包括第二主查询实体和第二次查询实体,则终端用第二主查询实体替换第一查询实体。
S412、终端输出第二结果。
进一步的,终端将第二结果输出给用户,具体实现方式可以参考上述S405,此处不再详细赘述。
至此,通过采用本申请实施例提供的基于知识图谱的问答方法,当终端接收到用户输入的具备不完整语义的自然查询语句(例如第二自然查询语句)时,终端能够结合预先已经存储的查询实体和实体特征信息(如本申请实施例中的第一查询实体和第 一实体特征信息),对当前问题的语义进行完善。进一步的,终端根据语义完善后的问题在知识图谱中查询,并将查询结果输出给用户,有效地解决了终端无法获不具备完整语义的自然查询语句的查询结果的问题。
可选的,终端删除存储的查询实体和实体特征信息(如第一查询实体和第一实体特征信息、或者,第二查询实体和第二实体特征信息)。具体的,在第一预设时长内,终端没有获取到新的自然查询语句,且实体和特征信息的存储时长超过第一预设时长,则终端删除已经存储的实体和特征信息,或者终端将已经存储的实体和特征信息置为无效。这样,能够有效地提高终端的存储空间的利用率,以及提高问答系统的时效性。其中,第一预设时长可以根据实际需求设定,本申请实施例对此不作限定。
此外,本申请实施例提供的基于知识图谱的问答方法还可以用于对话引导。通过该方法,终端能够根据用户的历史提问信息和预设的引导策略,对用户进行引导。
其中,引导策略是开发人员根据领域需求预先设置的,也可以是用户自定义设置的。引导策略存储于终端。
图7示出了本申请实施例提供的另一种基于知识图谱的问答方法的流程示意图。
结合图4,参考图7。如图7所示,本申请实施例提供的基于知识图谱的问答方法包括如下步骤:
终端执行S401-S404。具体的,在S404,终端采用下述任一方式存储第一查询实体和第一实体特征信息:
方式a、终端在第一存储空间存储第一查询实体和第一实体特征信息,并在第二存储空间存储第一查询实体和第一实体特征信息,该第一存储空间用于存储最新的查询实体和最新的实体特征信息,该第二存储空间用于存储终端确定的历史查询实体和历史实体特征信息。
方式b、终端在第三存储空间存储第一查询实体和第一实体特征信息,该第三存储空间用于存储终端已经确定的查询实体和实体特征信息,并标记最新的查询实体和实体特征信息。
然后,终端执行S405-S411。
在S411,具体的,若终端采用S404中方式a存储第一查询实体和第一实体特征信息,则终端在第二存储空间中存储第二查询实体和第二实体特征信息。同时,终端将第一存储空间中的第一查询实体更新为第二查询实体,将第一存储空间中的第一实体特征信息更新为第二实体特征信息,该更新过程可以参考上述S408,此处不予赘述。
若终端采用S404中方式b存储第一查询实体和第一实体特征信息,则终端在第三存储空间中存储第二查询实体和第二实体特征信息,并将第二查询实体标记为最新的查询实体,以及将第二实体特征信息标记为最新的实体特征信息。
在S411之后,本申请实施例提供的基于知识图谱的问答方法还包括S701:
S701、终端生成引导语。
终端根据存储的第一查询实体、第一查询实体信息、第二查询实体、第二查询实体信息,以及引导策略,生成引导语。
具体的,第一查询实体、第一查询实体信息、第二查询实体以及第二查询实体信息可以反映用户提问的意图以及用户感兴趣的问题。因此,第一查询实体、第一查询 实体信息、第二查询实体以及第二查询实体信息,结合引导策略后,终端生成引导语,以引导用户的后续操作。
示例性的,以终端为手机为例。如图8中的(a)所示,用户在手机的问答界面81的问答输入框82输入的第三自然查询语句“A的身高是多少?”。手机确定第三查询实体为“A”,第三实体特征信息维“身高”。接着,如图8中的(b)所示,手机根据第三查询实体和第三实体特征信息从知识图谱中查询到第三自然查询语句的第三结果并输出给用户。
同时,若引导策略为:实体为A时,引导A的“女儿”。因此,终端结合引导策略,并根据第三自然查询语句的第三查询实体和第三实体特征信息,终端生成第一引导语“您是否还需要了解A的女儿的身高?”。
随后,终端执行S412。
在S412之后,本申请实施例提供的基于知识图谱的问答方法还包括S702:
S702、终端输出第一引导语给用户。
终端输出第一引导语的具体方式,可以参考S412终端输出第二结果给用户的具体实现方式,此处不再详细赘述。
示例性的,参考图8,如图8(c)所示,终端在手机的显示界面上显示第三结果以及第一引导语给用户。
可选的,若用户接受终端的引导推荐,则向手机输入“是的”,或者“好啊”等内容,具体过程可以参考S401,此处不再赘述。
可以理解的是,S702可以和S412同时执行,也可以在S412之后执行,本申请对此不作限定。
可选的,终端可以删除存储的历史信息,包括查询实体(例如第一查询实体、第二查询实体)、实体特征信息(例如第一特征类型、第二特征类型)等信息,从而有效地提高终端的存储空间的利用率,以及提高问答系统的时效性。
在一种可能的实现方式中,终端确定用户上一次向终端提问的时刻到当前时刻的时长超过第一预设时长,且在第一预设时长内,终端没有再获取到新的自然查询语句。这种情况下,终端删除与该用户交互过程中存储的历史信息,或者,终端将与该用户交互过程中存储的历史信息置为无效。
在另一种可能的实现方式中,终端确定获取第一自然查询语句的时刻到当前时刻的时长超过第二预设时长时,终端删除时长1之前存储的历史信息,或者,终端将时长1之前存储的历史信息置为无效。其中,时长1小于第二预设时长,且时长1为时刻1到当前时刻的时长。时刻1为终端与用户交互过程中的任一时刻。
在又一种可能的实现方式中,终端确定存储的历史信息的数量大于第一阈值时,终端从存储时间最早的历史信息开始,按照历史信息的存储时间,删除n个历史信息,或将n的历史信息置为无效。其中,n为大于或等于1的正整数,且n小于第一阈值。第一阈值可以根据实际需求具体设定,本申请对此不作限定。
综上,本申请实施例提供了一种基于知识图谱的问答方法。当接收到用户输入的具备不完整语义的自然查询语句时,终端能够结合预先已经存储的实体和特征信息(如本申请实施例中的第一查询实体和第一实体特征信息),对当前问题的语义进行完善。 进一步的,终端根据语义完善后的问题在知识图谱中查询,并将该结果输出给用户。相比现有技术中,现有的问答系统仅在数据库中建立一对一的关系映射网,知识点与知识点之间的联系十分薄弱,因此反馈给用户的答案往往并不准确。本申请实施例提供的基于知识图谱的问答方法,能快速、精确的反馈答案给用户,并且有效地解决了终端无法获取不具备完整语义的自然查询语句的查询结果的问题。此外,本申请实施例提供的基于知识图谱的问答方法结合引导策略后,终端能够根据用户历史查询信息以及引导策略对用户进行引导推荐,提高了用户与终端的交互体验。
上述主要从方法的角度对本申请实施例提供的方案进行了介绍。为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
本申请实施例可以根据上述方法示例对基于知识图谱的问答装置进行功能模块的划分,例如,可以对应各个功能划分各个功能模块,也可以将两个或两个以上的功能集成在一个处理模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。需要说明的是,本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。
如图9所示,为本申请实施例提供的一种基于知识图谱的问答装置的结构示意图。所述问答装置用于基于知识图谱的跟踪问答,以及对话引导,例如用于执行图4或图7所示的方法。所述问答装置可以包括获取单元90、识别单元91、确定单元92、查询单元93、输出单元94。
获取单元90,用于获取第一自然查询语句,第一自然查询语句包括第一查询实体和第一实体特征信息,第一实体特征信息包括第一查询实体的属性或第一查询实体的关系中的至少一个。查询单元93,用于根据第一查询实体和所述第一实体特征信息,在所述知识图谱中查询以获得第一结果。输出单元94,输出查询单元93查询到的所述第一结果。获取单元90,还用于获取第二自然查询语句。确定单元92,用于根据第一查询实体或第一实体特征信息,确定第二自然查询语句缺失的部分。查询单元93,还用于根据确定单元92确定出的第二自然查询语句缺失的部分,在知识图谱中查询以获得第二结果。输出单元94,还用于输出查询单元93查询到的第二结果。
例如,结合图4,获取单元90可以用于执行S401和S406。确定单元92可以用于执行S408。查询单元93用于执行S403和S410。输出单元94可以用于执行S405和S412。
可选的,确定单元92,还用于在根据第一查询实体或第一实体特征信息,确定第二自然查询语句缺失的部分之前,确定第二自然查询语句缺失第二查询实体或第二实体特征信息,第二实体特征信息包括第二查询实体的属性或第二查询实体的关系中的至少一个。
确定单元92,具体用于若第二自然查询语句缺失第二查询实体,则根据第一查询 实体,确定第二查询实体。
确定单元92,还具体用于若第二自然查询语句缺失第二实体特征信息,则根据第一实体特征信息,确定第二实体特征信息。
例如,结合图4,确定单元92可以用于执行S408。
可选的,识别单元91,用于根据预设的规则,识别第二自然查询语句中的查询实体和实体特征信息,以得到第二查询实体或第二实体特征信息。结合图4,识别单元91可以用于执行S402和S407。
确定单元92,具体用于若识别单元91未得到所述第二查询实体,则确定第二自然查询语句缺失第二查询实体;若识别单元91未得到第二实体特征信息,则确定第二自然查询语句缺失第二实体特征信息。
例如,结合图4,识别单元91和确定单元92可以用于执行S402、S407。
可选的,识别单元91,具体用于将第二自然查询语句输入到第一预设模型,以得到初始查询实体或初始实体特征信息。
若得到初始查询实体,则根据预设算法和第二自然查询语句,对初始查询实体进行扩充;根据预设的词典和扩充后的初始查询实体,得到第二查询实体。若得到初始实体特征信息,则根据预设算法和第二自然查询语句,对初始实体特征信息进行扩充;根据词典和扩充后的初始实体特征信息,得到第二实体特征信息。其中,词典与知识图谱对应。
例如,结合图4,识别单元91可以用于执行S402、S407。
可选的,确定单元92,还用于根据第二查询实体、第二实体特征信息以及第二自然查询语句,采用预设的问题模型,确定第二自然查询语句的问题类型。
例如,结合图4,确定单元92可以用于执行S409。
可选的,确定单元92,还用于根据第二自然查询语句和第二自然查询语句缺失的部分,确定第二自然查询语句的问题模板。
确定单元92,还用于在预设的问题模板库中,确定目标查询语句。问题模板库包括m个问题模板以及m个查询语句,m个查询语句中的每个查询语句唯一对应一个问题模板,m为正整数。目标查询语句与目标问题模板对应,该目标问题模板为:问题模板库中,与第二自然查询语句的问题模板的相似度最大的模板。
查询单元93,还用于根据确定单元92确定出的第二自然查询语句的问题类型和目标查询语句,在知识图谱中查询以获得所述第二结果。
例如,结合图4,确定单元92可以用于执行S409,查询单元93可以用于执行S410。
可选的,确定单元92,还用于根据第一查询实体、第一实体特征信息、第二自然查询语句缺失的部分、第二自然查询语句以及预设的引导策略,确定引导语句,引导语句用于引导用户的下一步操作。输出单元94,还用于输出确定单元92确定出的所述引导语句。
例如,结合图7,确定单元92可以用于执行S701,输出单元94可以用于执行S702。
当然,本申请实施例提供的基于知识图谱的问答装置包括但不限于上述单元,例如该问答装置还可以包括存储单元95。存储单元95可以用于存储该问答装置的程序代码,还可以用于存储该问答装置在运行过程中获取的数据,如第一查询实体、第一 实体特征信息、第二查询实体、以及第二实体特征信息等。
作为一个示例,结合图3,基于知识图谱的问答装置中的获取单元90和输出单元94实现的功能与图3中的通信器件33的功能相同。识别单元91、确定单元92、查询单元93实现的功能与图3中的处理器31的功能相同。存储单元95实现的功能与图3中的存储器32的功能相同。
本申请实施例还提供一种芯片系统,如图10所示,该芯片系统包括至少一个处理器101和至少一个接口电路102。处理器101和接口电路102可通过线路互联。例如,接口电路102可用于从其它装置(例如基于知识图谱的问答装置的存储器)接收信号。又例如,接口电路102可用于向其它装置(例如处理器101)发送信号。示例性的,接口电路102可读取存储器中存储的指令,并将该指令发送给处理器101。当所述指令被处理器101执行时,可使得基于该问答装置执行上述实施例中的各个步骤。当然,该芯片系统还可以包含其他分立器件,本申请实施例对此不作具体限定。
本申请另一实施例还提供一种非易失性存储介质,该非易失性存储介质中存储有指令,当指令在基于知识图谱的问答装置上运行时,该问答装置执行上述方法实施例所示的方法流程中终端执行的各个步骤。
在一些实施例中,所公开的方法可以实施为以机器可读格式被编码在非易失性存储介质上的或者被编码在其它非瞬时性介质或者制品上的计算机程序指令。
图11示意性地示出本申请实施例提供的计算机程序产品的概念性局部视图,所述计算机程序产品包括用于在计算设备上执行计算机进程的计算机程序。
在一个实施例中,计算机程序产品是使用信号承载介质110来提供的。所述信号承载介质110可以包括一个或多个程序指令,其当被一个或多个处理器运行时可以提供以上针对图4或图7描述的功能或者部分功能。因此,例如,参考图4中S401~S412的一个或多个特征可以由与信号承载介质110相关联的一个或多个指令来承担。此外,图11中的程序指令也描述示例指令。
在一些示例中,信号承载介质110可以包含计算机可读介质111,诸如但不限于,硬盘驱动器、紧密盘(CD)、数字视频光盘(DVD)、数字磁带、存储器、只读存储记忆体(read-only memory,ROM)或随机存储记忆体(random access memory,RAM)等等。
在一些实施方式中,信号承载介质110可以包含计算机可记录介质112,诸如但不限于,存储器、读/写(R/W)CD、R/W DVD、等等。
在一些实施方式中,信号承载介质110可以包含通信介质113,诸如但不限于,数字和/或模拟通信介质(例如,光纤电缆、波导、有线通信链路、无线通信链路、等等)。
信号承载介质110可以由无线形式的通信介质113(例如,遵守IEEE 802.11标准或者其它传输协议的无线通信介质)来传达。一个或多个程序指令可以是,例如,计算机可执行指令或者逻辑实施指令。
在一些示例中,诸如针对图4或图7描述的基于知识图谱的问答装置可以被配置为,响应于通过计算机可读介质111、计算机可记录介质112、和/或通信介质113中的一个或多个程序指令,提供各种操作、功能、或者动作。
应该理解,这里描述的布置仅仅是用于示例的目的。因而,本领域技术人员将理解,其它布置和其它元素(例如,机器、接口、功能、顺序、和功能组等等)能够被取而代之地使用,并且一些元素可以根据所期望的结果而一并省略。另外,所描述的元素中的许多是可以被实现为离散的或者分布式的组件的、或者以任何适当的组合和位置来结合其它组件实施的功能实体。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件程序实现时,可以全部或部分地以计算机程序产品的形式来实现。该计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机执行指令时,全部或部分地产生按照本申请实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或者数据中心通过有线(例如同轴电缆、光纤、数字用户线(digital subscriber line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可以用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质(例如,软盘、硬盘、磁带),光介质(例如,DVD)、或者半导体介质(例如固态硬盘(solid state disk,SSD))等。
以上所述,仅为本申请的具体实施方式。熟悉本技术领域的技术人员根据本申请提供的具体实施方式,可想到变化或替换,都应涵盖在本申请的保护范围之内。
Claims (18)
- 一种基于知识图谱的问答方法,其特征在于,包括:获取第一自然查询语句,所述第一自然查询语句包括第一查询实体和第一实体特征信息,所述第一实体特征信息包括所述第一查询实体的属性或所述第一查询实体的关系中的至少一个;根据所述第一查询实体和所述第一实体特征信息,在所述知识图谱中查询以获得第一结果,输出所述第一结果;获取第二自然查询语句;根据所述第一查询实体或所述第一实体特征信息,确定所述第二自然查询语句缺失的部分;根据所述第二自然查询语句缺失的部分,在所述知识图谱中查询以获得第二结果,输出所述第二结果。
- 根据权利要求1所述的问答方法,其特征在于,在所述根据所述第一查询实体或所述第一实体特征信息,确定所述第二自然查询语句缺失的部分之前,所述问答方法还包括:确定所述第二自然查询语句缺失第二查询实体或第二实体特征信息,所述第二实体特征信息包括所述第二查询实体的属性或所述第二查询实体的关系中的至少一个;若所述第二自然查询语句缺失所述第二查询实体,则所述根据所述第一查询实体或所述第一实体特征信息,确定所述第二自然查询语句缺失的部分,包括:根据所述第一查询实体,确定所述第二查询实体;若所述第二自然查询语句缺失所述第二实体特征信息,则所述根据所述第一查询实体或所述第一实体特征信息,确定所述第二自然查询语句缺失的部分,包括:根据所述第一实体特征信息,确定所述第二实体特征信息。
- 根据权利要求2所述的问答方法,其特征在于,所述确定所述第二自然查询语句缺失第二查询实体或第二实体特征信息,包括:根据预设的规则,识别所述第二自然查询语句中的查询实体和实体特征信息,以得到所述第二查询实体或所述第二实体特征信息;若未得到所述第二查询实体,则确定所述第二自然查询语句缺失所述第二查询实体;若未得到所述第二实体特征信息,则确定所述第二自然查询语句缺失所述第二实体特征信息。
- 根据权利要求3所述的问答方法,其特征在于,所述根据预设的规则,识别所述第二自然查询语句中的查询实体和实体特征信息,以得到所述第二查询实体或所述第二实体特征信息,包括:将所述第二自然查询语句输入到第一预设模型,以得到初始查询实体或初始实体特征信息;若得到所述初始查询实体,则根据预设算法和所述第二自然查询语句,对所述初始查询实体进行扩充;根据预设的词典和扩充后的初始查询实体,确定所述第二查询实体;若得到所述初始实体特征信息,则根据预设算法和所述第二自然查询语句,对所述初始实体特征信息进行扩充;根据所述词典和扩充后的初始实体特征信息,确定所述第二实体特征信息;其中,所述词典与所述知识图谱对应。
- 根据权利要求2-4中任意一项所述的问答方法,其特征在于,所述问答方法还包括:根据所述第二查询实体、所述第二实体特征信息以及所述第二自然查询语句,采用预设的问题模型,确定所述第二自然查询语句的问题类型。
- 根据权利要求5所述的问答方法,其特征在于,所述根据所述第二自然查询语句缺失的部分,在所述知识图谱中查询以获得第二结果,包括:根据所述第二自然查询语句和所述第二自然查询语句缺失的部分,确定所述第二自然查询语句的问题模板;在预设的问题模板库中,确定目标查询语句;所述问题模板库包括m个问题模板以及m个查询语句,m个查询语句中的每个查询语句唯一对应一个问题模板,m为正整数;所述目标查询语句与目标问题模板对应,所述目标问题模板为:所述问题模板库中,与所述第二自然查询语句的问题模板的相似度最大的模板;根据所述第二自然查询语句的问题类型和所述目标查询语句,在所述知识图谱中查询以获得所述第二结果。
- 根据权利要求1-6中任意一项所述的问答方法,其特征在于,所述问答方法还包括:根据所述第一查询实体、所述第一实体特征信息、所述第二自然查询语句缺失的部分、所述第二自然查询语句以及预设的引导策略,确定引导语句,所述引导语句用于引导用户的下一步操作;输出所述引导语句。
- 一种基于知识图谱的问答装置,其特征在于,包括:获取单元,用于获取第一自然查询语句,所述第一自然查询语句包括第一查询实体和第一实体特征信息,所述第一实体特征信息包括所述第一查询实体的属性或所述第一查询实体的关系中的至少一个;查询单元,用于根据所述第一查询实体和所述第一实体特征信息,在所述知识图谱中查询以获得第一结果;输出单元,输出所述查询单元查询到的所述第一结果;所述获取单元,还用于获取第二自然查询语句;确定单元,用于根据所述第一查询实体或所述第一实体特征信息,确定所述第二自然查询语句缺失的部分;所述查询单元,还用于根据所述确定单元确定出的所述第二自然查询语句缺失的部分,在所述知识图谱中查询以获得第二结果;所述输出单元,还用于输出所述查询单元查询到的所述第二结果。
- 根据权利要求8所述的问答装置,其特征在于,所述确定单元,还用于在确定所述第二自然查询语句缺失的部分之前,确定所述 第二自然查询语句缺失第二查询实体或第二实体特征信息,所述第二实体特征信息包括所述第二查询实体的属性或所述第二查询实体的关系中的至少一个;所述确定单元,具体用于若所述第二自然查询语句缺失所述第二查询实体,则根据所述第一查询实体,确定所述第二查询实体;以及具体用于若所述第二自然查询语句缺失所述第二实体特征信息,则根据所述第一实体特征信息,确定所述第二实体特征信息。
- 根据权利要求9所述的问答装置,其特征在于,所述问答装置还包括识别单元;所述识别单元,用于根据预设的规则,识别所述第二自然查询语句中的查询实体和实体特征信息,以得到所述第二查询实体或所述第二实体特征信息;所述确定单元,具体用于若所述识别单元未得到所述第二查询实体,则确定所述第二自然查询语句缺失所述第二查询实体;若所述识别单元未得到所述第二实体特征信息,则确定所述第二自然查询语句缺失所述第二实体特征信息。
- 根据权利要求10所述的问答装置,其特征在于,所述识别单元具体用于:将所述第二自然查询语句输入到第一预设模型,以得到初始查询实体或初始实体特征信息;若得到所述初始查询实体,则根据预设算法和所述第二自然查询语句,对所述初始查询实体进行扩充;根据预设的词典和扩充后的初始查询实体,得到所述第二查询实体;若得到所述初始实体特征信息,则根据预设算法和所述第二自然查询语句,对所述初始实体特征信息进行扩充;根据所述词典和扩充后的初始实体特征信息,得到所述第二实体特征信息;其中,所述词典与所述知识图谱对应。
- 根据权利要求9-11中任意一项所述的问答装置,其特征在于,所述确定单元,还用于根据所述第二查询实体、所述第二实体特征信息以及所述第二自然查询语句,采用预设的问题模型,确定所述第二自然查询语句的问题类型。
- 根据权利要求12所述的问答装置,其特征在于,所述确定单元,还用于根据所述第二自然查询语句和所述第二自然查询语句缺失的部分,确定所述第二自然查询语句的问题模板;所述确定单元,还用于在预设的问题模板库中,确定目标查询语句;所述问题模板库包括m个问题模板以及m个查询语句,m个查询语句中的每个查询语句唯一对应一个问题模板,m为正整数;所述目标查询语句与目标问题模板对应,所述目标问题模板为:所述问题模板库中,与所述第二自然查询语句的问题模板的相似度最大的模板;所述查询单元,还用于根据所述确定单元确定出的所述第二自然查询语句的问题类型和所述目标查询语句,在所述知识图谱中查询以获得所述第二结果。
- 根据权利要求8-13中任意一项所述问答装置,其特征在于,所述确定单元,还用于根据所述第一查询实体、所述第一实体特征信息、所述第二自然查询语句缺失的部分、所述第二自然查询语句以及预设的引导策略,确定引导 语句,所述引导语句用于引导用户的下一步操作;所述输出单元,还用于输出所述确定单元确定出的所述引导语句。
- 一种基于知识图谱的问答装置,其特征在于,包括:存储器和一个或多个处理器;所述存储器和所述处理器耦合;所述存储器用于存储计算机程序代码,所述计算机程序代码包括计算机指令,当所述计算机指令被所述问答装置执行时,使得所述问答装置执行如权利要求1-7中任意一项所述的问答方法。
- 一种芯片系统,其特征在于,所述芯片系统应用于基于知识图谱的问答装置;所述芯片系统包括一个或多个接口电路和一个或多个处理器;所述接口电路和所述处理器通过线路互联;所述接口电路用于从所述问答装置的存储器接收信号,并向所述处理器发送所述信号,所述信号包括所述存储器中存储的计算机指令;当所述处理器执行所述计算机指令时,所述问答装置执行如权利要求1-7中任意一项所述的问答方法。
- 一种非易失性存储介质,其特征在于,包括计算机指令,当所述计算机指令在基于知识图谱的问答装置上运行时,使得所述问答装置实现如权利要求1-7中任意一项所述的问答方法。
- 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得所述计算机执行如权利要求1-7中任一项所述的问答方法。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
EP20890529.9A EP4053713A4 (en) | 2019-11-22 | 2020-11-23 | METHOD AND APPARATUS FOR QUESTIONS AND ANSWERS BASED ON A KNOWLEDGE GRAPH |
US17/750,508 US20220284060A1 (en) | 2019-11-22 | 2022-05-23 | Question Answering Method and Apparatus Based on Knowledge Graph |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201911155641.3A CN112836023A (zh) | 2019-11-22 | 2019-11-22 | 一种基于知识图谱的问答方法及装置 |
CN201911155641.3 | 2019-11-22 |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US17/750,508 Continuation US20220284060A1 (en) | 2019-11-22 | 2022-05-23 | Question Answering Method and Apparatus Based on Knowledge Graph |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2021098876A1 true WO2021098876A1 (zh) | 2021-05-27 |
Family
ID=75921829
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2020/130820 WO2021098876A1 (zh) | 2019-11-22 | 2020-11-23 | 一种基于知识图谱的问答方法及装置 |
Country Status (4)
Country | Link |
---|---|
US (1) | US20220284060A1 (zh) |
EP (1) | EP4053713A4 (zh) |
CN (1) | CN112836023A (zh) |
WO (1) | WO2021098876A1 (zh) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115248854B (zh) * | 2022-09-22 | 2023-03-03 | 中邮消费金融有限公司 | 一种基于知识图谱的自动问答方法、系统及存储介质 |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN106919655A (zh) * | 2017-01-24 | 2017-07-04 | 网易(杭州)网络有限公司 | 一种答案提供方法和装置 |
US20180276525A1 (en) * | 2015-12-03 | 2018-09-27 | Huawei Technologies Co., Ltd. | Method and neural network system for human-computer interaction, and user equipment |
CN108804525A (zh) * | 2018-04-27 | 2018-11-13 | 出门问问信息科技有限公司 | 一种智能回答方法及装置 |
CN108959627A (zh) * | 2018-07-23 | 2018-12-07 | 北京光年无限科技有限公司 | 基于智能机器人的问答交互方法及系统 |
CN109657238A (zh) * | 2018-12-10 | 2019-04-19 | 宁波深擎信息科技有限公司 | 基于知识图谱的上下文识别补全方法、系统、终端及介质 |
CN110427470A (zh) * | 2019-07-25 | 2019-11-08 | 腾讯科技(深圳)有限公司 | 问答处理方法、装置及电子设备 |
CN110444292A (zh) * | 2019-07-29 | 2019-11-12 | 北京爱医生智慧医疗科技有限公司 | 信息问答方法及系统 |
Family Cites Families (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9569724B2 (en) * | 2010-09-24 | 2017-02-14 | International Business Machines Corporation | Using ontological information in open domain type coercion |
US8935277B2 (en) * | 2012-03-30 | 2015-01-13 | Sap Se | Context-aware question answering system |
US8977646B2 (en) * | 2012-06-14 | 2015-03-10 | Ca, Inc. | Leveraging graph databases in a federated database system |
US20140108321A1 (en) * | 2012-10-12 | 2014-04-17 | International Business Machines Corporation | Text-based inference chaining |
US9477759B2 (en) * | 2013-03-15 | 2016-10-25 | Google Inc. | Question answering using entity references in unstructured data |
US10402453B2 (en) * | 2014-06-27 | 2019-09-03 | Nuance Communications, Inc. | Utilizing large-scale knowledge graphs to support inference at scale and explanation generation |
US11475065B2 (en) * | 2019-10-29 | 2022-10-18 | Neo4J Sweden Ab | Pre-emptive graph search for guided natural language interactions with connected data systems |
-
2019
- 2019-11-22 CN CN201911155641.3A patent/CN112836023A/zh active Pending
-
2020
- 2020-11-23 WO PCT/CN2020/130820 patent/WO2021098876A1/zh unknown
- 2020-11-23 EP EP20890529.9A patent/EP4053713A4/en active Pending
-
2022
- 2022-05-23 US US17/750,508 patent/US20220284060A1/en not_active Abandoned
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20180276525A1 (en) * | 2015-12-03 | 2018-09-27 | Huawei Technologies Co., Ltd. | Method and neural network system for human-computer interaction, and user equipment |
CN106919655A (zh) * | 2017-01-24 | 2017-07-04 | 网易(杭州)网络有限公司 | 一种答案提供方法和装置 |
CN108804525A (zh) * | 2018-04-27 | 2018-11-13 | 出门问问信息科技有限公司 | 一种智能回答方法及装置 |
CN108959627A (zh) * | 2018-07-23 | 2018-12-07 | 北京光年无限科技有限公司 | 基于智能机器人的问答交互方法及系统 |
CN109657238A (zh) * | 2018-12-10 | 2019-04-19 | 宁波深擎信息科技有限公司 | 基于知识图谱的上下文识别补全方法、系统、终端及介质 |
CN110427470A (zh) * | 2019-07-25 | 2019-11-08 | 腾讯科技(深圳)有限公司 | 问答处理方法、装置及电子设备 |
CN110444292A (zh) * | 2019-07-29 | 2019-11-12 | 北京爱医生智慧医疗科技有限公司 | 信息问答方法及系统 |
Also Published As
Publication number | Publication date |
---|---|
EP4053713A1 (en) | 2022-09-07 |
EP4053713A4 (en) | 2022-11-30 |
US20220284060A1 (en) | 2022-09-08 |
CN112836023A (zh) | 2021-05-25 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10657966B2 (en) | Better resolution when referencing to concepts | |
US11782981B2 (en) | Method, apparatus, server, and storage medium for incorporating structured entity | |
CN107797984B (zh) | 智能交互方法、设备及存储介质 | |
CN107818781B (zh) | 智能交互方法、设备及存储介质 | |
WO2019101083A1 (zh) | 一种语音数据处理方法、语音交互设备及存储介质 | |
WO2020147428A1 (zh) | 交互内容生成方法、装置、计算机设备及存储介质 | |
US11373047B2 (en) | Method, system, and computer program for artificial intelligence answer | |
US20160171119A1 (en) | Establishing User Specified Interaction Modes in a Question Answering Dialogue | |
CN110046227A (zh) | 对话系统的配置方法、交互方法、装置、设备和存储介质 | |
US11586689B2 (en) | Electronic apparatus and controlling method thereof | |
US10586528B2 (en) | Domain-specific speech recognizers in a digital medium environment | |
CN111813910B (zh) | 客服问题的更新方法、系统、终端设备及计算机存储介质 | |
CN110619050B (zh) | 意图识别方法及设备 | |
WO2020143186A1 (zh) | 推荐系统训练方法、装置、计算机设备及存储介质 | |
JP7488871B2 (ja) | 対話推薦方法、装置、電子機器、記憶媒体ならびにコンピュータプログラム | |
CN116501960B (zh) | 内容检索方法、装置、设备及介质 | |
US8407047B2 (en) | Guidance information display device, guidance information display method and recording medium | |
US11769013B2 (en) | Machine learning based tenant-specific chatbots for performing actions in a multi-tenant system | |
KR102285115B1 (ko) | 챗봇 기반의 웹페이지 내비게이션 장치 및 방법 | |
WO2021098876A1 (zh) | 一种基于知识图谱的问答方法及装置 | |
WO2021239078A1 (zh) | 领域识别的方法、交互的方法、电子设备及存储介质 | |
JP2024056039A (ja) | 情報処理装置、情報処理システム、情報処理方法、及びプログラム | |
CN111444321A (zh) | 问答方法、装置、电子设备和存储介质 | |
CN117932022A (zh) | 一种智能问答方法、装置、电子设备及存储介质 | |
JP2017072964A (ja) | 情報分析装置及び情報分析方法 |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20890529 Country of ref document: EP Kind code of ref document: A1 |
|
ENP | Entry into the national phase |
Ref document number: 2020890529 Country of ref document: EP Effective date: 20220530 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |