Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Based on the above, an embodiment of the present invention provides a method for constructing a task-based intelligent dialog based on a knowledge graph, as shown in fig. 1, which includes the following steps:
and S1, constructing a knowledge graph, and setting an intention entity and a word slot entity in the knowledge graph.
The method comprises the steps of setting an intention entity and a word slot entity in a knowledge graph, wherein the intention entity and the word slot entity are defined firstly, and the definition process of the intention and word slot entity can be manually set through a front-end interface or can be defined in a configuration file mode.
Then, setting a word slot entity structure and an intention entity structure, specifically, the word slot entity structure and the intention entity structure are as follows:
the word slot entity structure comprises:
the query times are used for limiting the times of querying the missing word slots in the multi-turn conversation process;
the inquiry call technique is used for limiting words which remind the user in a way of asking when the current word slot is lacked; specifically, the method is to supplement a word slot inquiry dialogue in the following conversation process, wherein the word slot inquiry dialogue can be a series of question lists or a single question;
the failed speech technology is used for limiting the returned speech when the current word slot fails to acquire the answer;
whether it is necessary to fill in, is used to define whether the current word slot must be carried when inquiring about the intent.
The intended entity structure is as follows:
a response mode for limiting the words replied under the condition that the current intention is met; either a fixed utterance or a third party link may be invoked to dynamically generate a reply;
an intent tag for defining a current entity as an intent entity;
a failed utterance for defining an utterance replied when the current intent to obtain an answer fails; for example, in the process of calling the third-party link, if the third-party link fails, failure reply is carried out;
the inquiry times are used for limiting the times of back inquiry when the map structure to which the current intention belongs is determined; for example, if there are multiple parent-level intentions for the first query, the graph structure to which the current intent belongs is determined by a question-back method, and the number of question-back times is limited in the query process.
Different structural attributes are set in the intention entity and the word slot entity, so that the generation of later-stage conversation and reply can be conveniently guided, unreasonable reply caused by machine learning or deep learning is avoided, the output of a machine is strictly controlled, and the accuracy of conversation is ensured.
S2, setting the intention entities to point to the word slot entities or point to other intention entities, wherein no mutual relation exists between the word slot entities.
By setting the intention entity to point to the word slot entity or to point to other intention entities, the word slot related to the intention entity can be positioned through the intention entity in the question-answering conversation process; location of the intent entity to other associated intent entities can also be implemented, enabling jumping of intents in multiple rounds of dialog.
Specifically, the association relationship between the intention entities and the word slot entity can refer to fig. 2, for example, intention entity a is connected to word slot entity a, word slot entity B, and intention entity B.
And the intention entity allows no word slot entity to exist and independently exists, for example, the intention of inquiring the accumulation fund can be defined, and no parameter is needed in the inquiry process, so the intention of inquiring the accumulation fund can be set as a single accumulation fund inquiry entity in the knowledge graph.
In addition, the same intent entity may correspond to multiple parent intent entities, such as intent entity C in fig. 2, with two parent intents, intent entity B and intent entity D. When a plurality of parent level intentions exist, determining the atlas structure to which the current intentions belong in a mode of question return; for example, during a session, if intent C is first located, the current intent entity relationship would be asked in reverse to belong to either B or D. For example, if intention C is a Kendeji order, intention D is a McDonald order, and intention B is a definite hamburger, then the following form of task class conversation is supported during the query process:
the user: i want to define a hamburger
The robot comprises: whether you want kendir or mcdonald's labor
The user: diken bar
The robot comprises: hamburger which has reserved kendirk for you
The conversation and reply generation process of the intelligent dialogue system obtained by the knowledge graph-based task intelligent dialogue construction method is as follows:
when a user inputs a text, firstly, judging whether the input of the user is in a first inquiry or unintentional state through dialogue state tracking, if so, performing intention identification, judging whether the input of the user has an intention, and if not, directly generating a reply. If the current intention entity exists, the intention is linked into the intention entity in the knowledge graph, whether the current intention entity has multi-level intention is judged through the link relation of the intention entity in the knowledge graph, if yes, the reverse parent intention inquiry is confirmed, if not, the current intention is located in a parent node, then a word slot in a user input text is identified, meanwhile, the word slot related to the current intention entity is inquired, the word slot identified in the user input text is associated with the word slot inquired by the current intention entity, whether the current intention lacks the word slot is judged, if the word slot information lacks, the inquiry is carried out according to the inquiry technology in the word slot attribute, and the conversation is recorded. And if the word slot is not missing, judging whether the current intention is associated with other intention entities, if not, directly generating an intention answer in a response mode in the intention entities, otherwise, inquiring and confirming the associated intention, recording the session process and transferring the session process to the next round of session.
When the user inputs a non-initial query, firstly, judging whether the last conversation process is a question sentence with a missing word slot according to the conversation state, if so, identifying the word slot for the input of the user, if so, associating the word slot with a word slot entity detected by an intention entity, storing a conversation record, and transferring the question-answering process to the process 2 of the figure 3. If no word slot exists, judging whether the current word slot inquiry reaches the upper limit according to the inquiry time attribute in the word slot entity, if so, replying according to the failed word operation in the word slot entity attribute, otherwise, inquiring according to the inquiry word operation in the entity attribute. If the last session is not the intention query in the last session process, it needs to be further determined whether the last session is the intention query, and if not, it is determined that the session link is not entered, and the session is transferred to the process 3 of fig. 3, and the flow of intention recognition is performed again. Otherwise, judging whether the current input of the user is the intention of the intention entity link, if so, transferring the conversation state to the process 1 of the figure 3, judging whether the intention of the link has the lack of a word slot, otherwise, judging whether the current intention inquiry reaches the upper limit, if so, replying the failed operation in the attribute of the intention entity, otherwise, inquiring again according to the intention inquiry operation in the attribute of the intention entity, and recording the conversation.
During the generation process of conversation and reply, the intention and word slot entities identified based on template matching, deep learning or machine learning are linked into the knowledge graph, and the word slot entities related to the intention entities in the knowledge graph and the identified word slots are combined to respond to the input of the user, so that the whole process of the task-class dialog system is realized; and nodes of the knowledge graph are recorded in the session process based on the knowledge graph, and the conversation state is utilized for tracking, so that multiple rounds of conversation in the same task are realized.
According to the invention, the intentions and word slots in the task question-answering are linked into the construction process of the knowledge graph, the structural advantages of the knowledge graph are fully utilized, the relation between different intentions and word slots is obtained, the configuration of the intentions and word slots is reduced, and the correlation between different tasks is facilitated; and in the flow direction of tasks among entities in the map, the intention entities are set to point to the word slot entities or other intention entities in a one-way mode, and the word slot entities do not have mutual relations, so that the structure of the map entities is simplified, the intention entities can be enabled to efficiently find the word slot entities or other intention entities related to the intention entities, and jumping among intentions and reverse inquiry of the intentions are realized.
Based on the above method for constructing task-based intelligent dialogs based on the knowledge graph, the invention also provides a system for constructing task-based intelligent dialogs based on the knowledge graph, as shown in fig. 4, which comprises the following functional modules:
the map building module 10 is used for building a knowledge map, and setting an intention entity and a word slot entity in the knowledge map;
and an entity association setting module 20, configured to set that the intent entity points to a word slot entity or points to another intent entity, where no mutual relationship exists between the word slot entities.
The execution mode of the system for establishing task-based intelligent dialogues based on the knowledge graph is basically the same as that of the method for establishing task-based intelligent dialogues based on the knowledge graph, and therefore, detailed description is omitted.
The server in this embodiment is a device for providing computing services, and generally refers to a computer with high computing power, which is provided to a plurality of consumers via a network. The server of this embodiment includes: a memory including an executable program stored thereon, a processor, and a system bus, it will be understood by those skilled in the art that the terminal device structure of the present embodiment does not constitute a limitation of the terminal device, and may include more or less components than those shown, or some components in combination, or a different arrangement of components.
The memory may be used to store software programs and modules, and the processor may execute various functional applications of the terminal and data processing by operating the software programs and modules stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, a phonebook, etc.) created according to the use of the terminal, etc. Further, the memory may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The executable program of the task-based intelligent dialogue building method based on the knowledge graph is contained in a memory, the executable program can be divided into one or more modules/units, the one or more modules/units are stored in the memory and executed by a processor to complete the information acquisition and implementation process, and the one or more modules/units can be a series of computer program instruction segments capable of completing specific functions and are used for describing the execution process of the computer program in the server. For example, the computer program may be divided into a graph building module 10, an entity association setting module 20.
The processor is a control center of the server, connects various parts of the whole terminal equipment by various interfaces and lines, and executes various functions of the terminal and processes data by running or executing software programs and/or modules stored in the memory and calling data stored in the memory, thereby performing overall monitoring of the terminal. Alternatively, the processor may include one or more processing units; preferably, the processor may integrate an application processor, which mainly handles operating systems, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into the processor.
The system bus is used to connect various functional units in the computer, and can transmit data information, address information and control information, and the types of the functional units can be PCI bus, I SA bus, VESA bus and the like. The system bus is responsible for data and instruction interaction between the processor and the memory. Of course, the system bus may also access other devices such as network interfaces, display devices, etc.
The server at least includes a CPU, a chipset, a memory, a disk system, and the like, and other components are not described herein again.
In the embodiment of the present invention, the executable program executed by the processor included in the terminal specifically includes: a task-class intelligent dialogue construction method based on a knowledge graph comprises the following steps:
constructing a knowledge graph, and setting an intention entity and a word slot entity in the knowledge graph;
setting the intention entities to point to word slot entities or point to other intention entities, wherein no mutual relation exists between the word slot entities.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art would appreciate that the modules, elements, and/or method steps of the various embodiments described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.