CN117609452A - Dialogue reply generation method, device, equipment and storage medium - Google Patents

Dialogue reply generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN117609452A
CN117609452A CN202311587740.5A CN202311587740A CN117609452A CN 117609452 A CN117609452 A CN 117609452A CN 202311587740 A CN202311587740 A CN 202311587740A CN 117609452 A CN117609452 A CN 117609452A
Authority
CN
China
Prior art keywords
semantic
sentence
current
semantic node
dialogue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311587740.5A
Other languages
Chinese (zh)
Inventor
王定
华克儒
牟小峰
杨瑞
程优优
刘金艳
尤太林
刘烨
徐国粮
黄孝江
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Midea Group Co Ltd
Midea Group Shanghai Co Ltd
Original Assignee
Midea Group Co Ltd
Midea Group Shanghai Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Midea Group Co Ltd, Midea Group Shanghai Co Ltd filed Critical Midea Group Co Ltd
Priority to CN202311587740.5A priority Critical patent/CN117609452A/en
Publication of CN117609452A publication Critical patent/CN117609452A/en
Pending legal-status Critical Current

Links

Abstract

The invention relates to a dialogue reply generation method, a device, equipment and a storage medium, which comprise the following steps: acquiring a current sentence of a current round of dialogue; determining a first semantic node corresponding to the current round of dialogue in a plurality of semantic nodes included in a pre-constructed semantic space, and determining a target edge matched with a preset character and a current sentence in at least one jump edge from the first semantic node, wherein the semantic space further comprises a plurality of jump edges, and each jump edge is used for connecting two semantic nodes and carrying the preset character; and generating a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot position information collected by the first semantic node, and completing the current round of dialogue. According to the method provided by the invention, the semantic nodes corresponding to the current round of dialogue are determined by jumping among the semantic nodes in the pre-constructed semantic space, so that the reply sentence is generated, the accuracy of dialogue reply is effectively improved, and the manpower, material resources and time cost are reduced to a certain extent.

Description

Dialogue reply generation method, device, equipment and storage medium
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for generating a dialogue reply.
Background
With the development of artificial intelligence, a man-machine interaction mode of realizing real-time dialogue with a user through a dialogue system gradually becomes a research key point. At present, human-computer interaction is mostly carried out by adopting a neural network model, a large amount of dialogue histories are used for training the model in the early stage, and dialogue replies are directly generated through the trained model.
However, a large amount of training corpus is needed in the model training stage, manual labeling is needed, a large amount of manpower, material resources and time cost are consumed, and the accuracy of reply caused by the fact that information in a front-wheel dialogue cannot be accurately inherited for multiple-wheel dialogue is low.
Disclosure of Invention
In order to solve the technical problems, the embodiments of the present disclosure provide a method, an apparatus, a device, and a storage medium for generating a dialogue reply, which effectively improve the accuracy of the dialogue reply and reduce the cost of manpower, material resources, and time to a certain extent.
In a first aspect, an embodiment of the present disclosure provides a method for generating a dialog reply, including:
acquiring a current sentence of a current round of dialogue;
Determining a first semantic node corresponding to the current round of dialogue in a plurality of semantic nodes included in a pre-constructed semantic space, and determining a target edge matched with a preset character and the current sentence in at least one jump edge from the first semantic node, wherein the semantic space further comprises a plurality of jump edges, and each jump edge is used for connecting two semantic nodes and carrying the preset character;
and generating a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot position information collected by the first semantic node, and completing the current dialogue.
In a second aspect, an embodiment of the present disclosure provides a dialog reply generation device, including:
the acquisition unit is used for acquiring the current sentence of the current round of dialogue;
the first determining unit is used for determining a first semantic node corresponding to the current round of dialogue in a plurality of semantic nodes included in a pre-constructed semantic space, wherein the plurality of semantic nodes are connected through a jump edge, and the jump edge comprises preset characters;
the second determining unit is used for determining a target edge matched with the current sentence and a preset character in at least one jump edge connected with the first semantic node;
And the generating unit is used for generating a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot position information collected by the first semantic node, and completing the current round of dialogue.
In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement a dialog reply generation method as described above.
In a fourth aspect, embodiments of the present disclosure provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of a dialog reply generation method as described above.
The embodiment of the disclosure provides a dialogue reply generation method, which comprises the following steps: acquiring a current sentence of a current round of dialogue; determining a first semantic node corresponding to the current round of dialogue in a plurality of semantic nodes included in a pre-constructed semantic space, and determining a target edge matched with a preset character and a current sentence in at least one jump edge from the first semantic node, wherein the semantic space further comprises a plurality of jump edges, and each jump edge is used for connecting two semantic nodes and carrying the preset character; and generating a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot position information collected by the first semantic node, and completing the current round of dialogue. According to the method provided by the invention, the semantic nodes corresponding to the current round of dialogue are determined by jumping among the semantic nodes in the pre-constructed semantic space, so that the reply sentence is generated, the accuracy of dialogue reply is effectively improved, and the manpower, material resources and time cost are reduced to a certain extent.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
Fig. 1 is a schematic diagram of an application scenario provided in an embodiment of the present disclosure;
fig. 2 is a flowchart of a method for generating a dialogue reply according to an embodiment of the disclosure;
FIG. 3 is a schematic structural diagram of a semantic space according to an embodiment of the present disclosure;
FIG. 4 is a schematic diagram of a refinement flow of S203 in the dialog reply generation method shown in FIG. 2;
fig. 5 is a schematic structural diagram of a dialogue reply generation device according to an embodiment of the disclosure;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein; it will be apparent that the embodiments in the specification are only some, but not all, embodiments of the disclosure.
Aiming at the technical problems, the embodiment of the disclosure provides a dialogue reply generation method, which determines a last semantic node of each round of dialogue through the jump among semantic nodes in a pre-constructed semantic space, determines the semantic node corresponding to the round of dialogue according to the semantic node pointed by the jump edge of the last semantic node, generates reply sentences according to sentence pairs included in the semantic node corresponding to the round of dialogue, fully considers the relevance among the rounds of dialogue through the connection relation among the semantic nodes, and effectively improves the generation efficiency and the accuracy of the reply sentences. And in particular by one or more of the following examples.
Specifically, the dialogue reply generation method may be executed by a terminal or a server. In particular, the terminal or the server may pass through. For example, in one application scenario, as shown in FIG. 1, the server 12 builds a semantic space. The terminal 11 acquires the semantic space from the server 12 and generates a reply sentence to the current sentence through the semantic space constructed in advance. In another application scenario, the server 12 builds a semantic space. Further, the server 12 generates a reply sentence to the current sentence through a semantic space constructed in advance. In yet another application scenario, the terminal 11 builds a semantic space. Further, the terminal 11 generates a reply sentence to the current sentence through a semantic space constructed in advance.
It can be appreciated that the dialog reply generation method provided by the embodiments of the present disclosure is not limited to several possible scenarios as described above. The following describes in detail an example in which a terminal constructs a semantic space and generates a reply sentence of a current sentence through the previously constructed semantic space.
Fig. 2 is a flow chart of a dialogue reply generation method provided by an embodiment of the present disclosure, which is applied to a terminal deployed with a man-machine interaction intelligent system, and specifically includes the following steps S201 to S203 as shown in fig. 2:
s201, acquiring a current sentence of a current round of dialogue.
It may be understood that, a current sentence of a current round of dialogue is obtained, and a session is usually started by a user, where a session includes at least one round of dialogue, and the current round of dialogue may be the first round of dialogue of the session or may be the non-first round of dialogue, where "current round of dialogue", "previous round of dialogue", "history round of dialogue", etc. referred to in this scheme refer to a certain round or a plurality of rounds of dialogue in a session, and the current sentence may be a sentence in different forms such as audio or text sent by the user in the current round of dialogue, for example, the current sentence is "booked an air ticket". It can be understood that, when a user and a terminal interact once, each sentence output forms a round of dialogue, and the application scenario in the embodiment of the present disclosure is that a sentence sent by a certain end of a round of dialogue is obtained and recorded as a current sentence of a current round of dialogue.
S202, determining a first semantic node corresponding to the current round of dialogue among a plurality of semantic nodes included in a pre-constructed semantic space, and determining a target edge matched with a preset character and the current sentence in at least one jump edge from the first semantic node.
The semantic space further comprises a plurality of jump edges, wherein each jump edge is used for connecting two semantic nodes and carries preset characters; the semantic nodes are connected through a skip edge, and the skip edge comprises preset characters.
The semantic space is associated with refrigerator food material management, and is constructed based on data samples corresponding to the refrigerator food material management.
It can be understood that a semantic space is pre-constructed, specifically, preset characters carried by each semantic node and a skip edge between semantic nodes in the semantic space can be manually configured, the situation is applicable to a conversation scene with a smaller range, data samples in the field can be collected based on a certain vertical field, such as a refrigerator food material management field, the semantic space is constructed through model training, a specific construction method of the semantic space is omitted, and the situation can be determined by a user according to the user requirement. The semantic space comprises a root semantic node, a plurality of semantic nodes and a plurality of jump edges, each semantic node comprises at least one jump edge from the semantic node, each jump edge carries a preset character, the preset character is used for representing the jump relation between two semantic nodes connected with the jump edge, the preset character can be a word, an incomplete sentence or an complete sentence, such as an address, and the plurality of semantic nodes can be connected and jumped through the jump edges. The first semantic node may be a root semantic node or a history semantic node.
It may be understood that, based on S201 above, a first semantic node corresponding to the current round of dialogue is determined among a plurality of semantic nodes included in the semantic space, a second semantic node corresponding to the current round of dialogue may be determined by the first semantic node, the first semantic node may be regarded as a previous semantic node, the first semantic node may be regarded as a query node of the current round of dialogue, and the second semantic node may be regarded as the current semantic node.
Optionally, the determining, among the plurality of semantic nodes included in the pre-constructed semantic space, the first semantic node corresponding to the current round of dialogue may be specifically implemented by the following steps:
determining a plurality of historical semantic nodes from a plurality of semantic nodes included in the semantic space, wherein the plurality of historical semantic nodes comprise semantic nodes corresponding to the previous dialog; the first semantic node is determined among the plurality of historical semantic nodes.
The historical semantic nodes comprise at least part of semantic nodes related to the target dialogue task corresponding to the current dialogue, and at least part of semantic nodes may comprise root semantic nodes.
It can be understood that whether the current dialogue is the first dialogue is judged, the first dialogue is that the man-machine interaction intelligent system is started and then the man-machine interaction intelligent system is started for the first time, if the current dialogue is the first dialogue, the root semantic node is directly used as the first semantic node corresponding to the current dialogue. If the current round of dialogue is not the first round of dialogue, that is, at least one round of previous dialogue is completed before the current round of dialogue, a plurality of history semantic nodes are obtained, wherein the history semantic nodes refer to semantic nodes corresponding to the previous dialogue generated before the current round of dialogue, all semantic nodes corresponding to the previous dialogue from the first round of dialogue to the current round of dialogue can be used as history semantic nodes, a certain number of semantic nodes corresponding to the previous dialogue generated before the current round of dialogue can be used as history semantic nodes according to time sequence, the number of the plurality of history semantic nodes is not limited, and the history semantic nodes can be determined according to user requirements. After a plurality of history semantic nodes are acquired, a first semantic node is determined in the plurality of history semantic nodes.
Optionally, the determining the first semantic node among the plurality of historical semantic nodes may be specifically implemented by the following steps:
sorting the plurality of history semantic nodes according to the time mark to obtain a plurality of sorted history semantic nodes; determining a current historical semantic node from the plurality of ordered historical semantic nodes; carrying out semantic matching on preset characters of each skip edge starting from the current historical semantic node and the current sentence, and calculating the matching degree; if the matching degree is greater than or equal to a preset threshold value, determining the current historical semantic node as the first semantic node; or if the matching degree is smaller than the preset threshold value, continuing to determine the next historical semantic node until the first semantic node is determined or the plurality of historical semantic nodes are traversed.
It can be understood that the plurality of history semantic nodes are ordered according to time, so as to obtain a plurality of ordered history semantic nodes, after each round of dialogue determines the corresponding semantic node, a time mark is marked on the semantic node, and the time mark is the generation time of the round of dialogue, for example, the generation time can be the time of acquiring the current sentence. A current historical semantic node is then determined from the ranked plurality of historical semantic nodes, e.g., by traversing the plurality of historical semantic nodes in a time-sequential manner. After determining the current historical semantic nodes, calculating the semantic matching degree of preset characters carried by each skip edge starting from the current historical semantic nodes and the current sentence, if the current historical semantic nodes have skip edges with the matching degree larger than or equal to a preset threshold value, directly determining the current historical semantic nodes as first semantic nodes and determining the skip edges as target edges, or selecting a certain number of current historical semantic nodes from the plurality of historical semantic nodes, calculating the matching degree of the preset characters carried by the skip edges starting from each current historical semantic node and the current sentence, sequencing all the matching degrees according to the sequence from large to small, and taking the current historical semantic node corresponding to the skip edge with the largest matching degree value and larger than the preset threshold value as the first semantic node. If all the matching degrees of the calculated current historical semantic nodes are smaller than a preset threshold value, continuing to traverse from the plurality of historical semantic nodes to determine the next historical semantic node, and then calculating the matching degree of the preset characters carried by each jump edge from the next historical semantic node and the current sentence until the first semantic node is determined or the plurality of historical semantic nodes are traversed.
The plurality of history semantic nodes further comprise a third semantic node in an unfinished state, and any semantic node pointed by all jump edges of the third semantic node in the unfinished state is not the semantic node corresponding to the previous dialog.
It can be understood that each history semantic node further includes a state identifier, where the state identifier includes an incomplete state and a complete state, the incomplete state refers to that any semantic node pointed by a plurality of jump edges from the semantic node is not a history semantic node corresponding to a current round of dialogue (or is a node that the current round of dialogue does not go through), the third semantic node is not a semantic node corresponding to a previous round of dialogue, and the plurality of history semantic nodes further includes a third semantic node in the incomplete state. It is understood that each hop edge in the semantic space has a directed semantic node, and a semantic node in an unfinished state actually refers to other semantic nodes that do not continue to hop down from the semantic node in the session, or that all hop edges from the semantic node have not been experienced as target edges in the session, but some hop edges from the semantic node may have been experienced as target edges in other sessions. One possible case is that the session corresponding to the third semantic node and the current dialogue belong to different session tasks, and another possible case is that the session corresponding to the third semantic node and the current dialogue belong to the same session task, but the session corresponding to the third semantic node is not the previous session, for example, the session performs 10 sessions, the previous session refers to 4 th to 10 th sessions, and the session corresponding to the third semantic node may be 2 nd session.
Optionally, the determining the current historical semantic node from the sequenced plurality of historical semantic nodes may be specifically implemented by the following steps:
traversing the plurality of sequenced historical semantic nodes; and if the first semantic node is not determined when traversing to the root semantic node, directly determining the third semantic node as the current historical semantic node.
It may be appreciated that, in the case where the plurality of history semantic nodes includes the root semantic node, if the first semantic node is still not determined when traversing to the root semantic node, or the first semantic node is still not determined after traversing a certain number of history semantic nodes, the third semantic node is determined as the current history semantic node, and the plurality of history semantic nodes may include at least one third semantic node, in which case the at least one third semantic node may be ordered according to time, and the current history semantic node is determined after traversing the at least one third semantic node after the ordering.
The method comprises the steps of obtaining the matching degree of preset characters and current sentences carried by all jump edges from a first semantic node, determining the jump edge with the largest matching degree value and larger than a preset threshold value as a target edge, wherein a plurality of target edges possibly exist in the same first semantic node, and the semantic nodes pointed by different target edges are different. In the case that the first semantic node has a plurality of target edges, one final target edge may be determined from the plurality of target edges, or the subsequent step S203 may be performed for each target edge to generate a reply sentence corresponding to each target edge, and a final reply sentence for the current sentence may be determined based on each reply sentence.
S203, generating a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot position information collected by the first semantic node, and completing the current round of dialogue.
It can be understood that, on the basis of S202 above, a second semantic node pointed by the target edge is determined, where the second semantic node is a semantic node corresponding to the current round of dialogue, and after each round of dialogue determines the corresponding semantic node, key information in the corresponding round of dialogue and/or the previous round of dialogue is collected, and the key information is used as slot information of the semantic node, for example, for a task type dialogue for food material management of a refrigerator, the slot information may be specific food material, food material related data information, and refrigerator related information related to the previous round of dialogue, for example, the previous round of dialogue is a task type dialogue related to food material management of the refrigerator: and u is that the watermelon is put into a refrigerator. The method is characterized in that the watermelon is good, the watermelon is recorded, the groove information collected by the semantic node corresponding to the previous dialogue comprises the watermelon and the refrigerator, then the user speaks the current sentence of storing the watermelon in the refrigerator, and the groove information collected by the semantic node comprises the watermelon, the refrigerator and the refrigerator. The method comprises the steps that slot information collected by a first semantic node is obtained, a reply sentence of a current sentence is generated according to the slot information and a second semantic node, a current round of dialogue is completed, the current round of dialogue comprises the current sentence sent out by one end and the reply sentence sent out by the other end aiming at the current sentence, the second semantic node can be identified as a completion state, and the time identification of the second semantic node can be the time sent out by the current sentence.
Referring to fig. 3, an exemplary, fig. 3 is a schematic structural diagram of a semantic space provided by an embodiment of the present disclosure, where the semantic space includes a root semantic node and semantic nodes 1 to 9, the semantic nodes 1 to 6 are marked as a completion state, and are semantic nodes corresponding to previous dialogs, after obtaining a current sentence of a current round of dialogs, in the case that the current round of dialogs is not a first round of dialogs, the root semantic node and the semantic nodes 1 to 6 are used as history semantic nodes, 6 history semantic nodes are sequenced according to time, each history semantic node is traversed, and a newly determined semantic node is used as a current history semantic node, and a matching degree between a preset character carried by each skip edge starting from the current history semantic node and the current sentence is calculated. In a possible case that the semantic node 6 is the most recently determined semantic node, if the semantic node 6 has no jump edge matched with the current sentence, the semantic node 6 reaches the semantic node 5 along the jump edge 1 of the semantic node 6, the semantic node 6 is connected with the semantic node 5 through the jump edge 1, whether the semantic node 5 has the jump edge matched with the current sentence or not is judged, when the semantic node 6 and the semantic node 5 are traversed to the root semantic node, the calculated matching degree is still smaller than a preset threshold, that is, the first semantic node is not determined after 3 semantic nodes are traversed, in this case, the root semantic node can start to continue traversing the semantic node 1 to the semantic node 4 according to the connection sequence until the first semantic node is determined or all the history semantic nodes are traversed, or, in the case that the first semantic node is not yet determined after traversing to the root semantic node, a third semantic node in an unfinished state, such as semantic node 4, is obtained from the remaining un-traversed historical semantic nodes, and each jump edge from semantic node 4 does not point to any semantic node, in this case, semantic node 4 is directly used as the current historical semantic node without traversing semantic node 1 to semantic node 3, if there is a jump edge with matching degree greater than a preset threshold value in semantic node 4, semantic node 4 is determined as the first semantic node, if there is no jump edge with matching degree greater than a preset threshold value in semantic node 4, semantic node 3 to semantic node 1 are traversed according to the connection sequence from semantic node 4 until the first semantic node is determined or all the historical semantic nodes are traversed. In another possible case, the semantic node 4 is the most recently determined semantic node, if the first semantic node is still not determined after 3 semantic nodes are traversed from the semantic node 4, that is, the first semantic node is still not determined after traversing to the semantic node 2, in this case, the third semantic node which is not traversed to be in an unfinished state may be used as the current historical semantic node, and the subsequent step of determining the first semantic node is referred to the above description and will not be repeated herein.
According to the dialogue reply generation method, through the skip among semantic nodes in the pre-constructed semantic space, the first semantic node corresponding to the current dialogue is determined, the second semantic node corresponding to the current dialogue is determined according to the semantic node pointed by the skip edge of the first semantic node, reply sentences are generated according to sentences included in the semantic node corresponding to the current dialogue, previous dialogue collected by the first semantic node and slot information pairs of the current dialogue, the semantic nodes corresponding to the previous dialogue can be traced back through connection relations among the semantic nodes, relevance among each dialogue is fully considered, ambiguity of the sentences is reduced, the current sentences are accurately rewritten, complete sentences are generated, and reply sentences are generated according to the complete sentences, so that generation efficiency and accuracy of the reply sentences are effectively improved.
On the basis of the foregoing embodiment, fig. 4 is a schematic diagram of a refinement flow of S203 in the dialog reply generation method shown in fig. 1, and optionally, based on the second semantic node pointed by the target edge and the slot information collected by the first semantic node, a reply sentence of the current sentence is generated, which specifically includes the following steps S401 to S402 shown in fig. 4:
The semantic node further comprises a sentence pair, wherein the sentence pair comprises at least one first sentence and at least one second sentence, and the semantics of the at least one first sentence are the same.
It can be appreciated that the semantic node further includes a sentence pair, where the sentence pair includes at least one first sentence and at least one second sentence, where the at least one first sentence has the same semantic meaning, for example, the first sentence is a semantic meaning of "how good the tomorrow is," "how good the tomorrow is," and the like, and the at least one second sentence may have a semantic meaning identical to the sentence, or may be a completely different sentence, for example, the second sentence is a semantic meaning of "good tomorrow," "good tomorrow is," and the like, or the second sentence is a semantic meaning of "where the tomorrow is to be queried," and the like, which characterizes places.
S401, rewriting the current sentence according to at least one first sentence included in the second semantic node pointed by the target edge and slot position information collected by the first semantic node, and generating a complete sentence of the current sentence.
It may be appreciated that determining the second semantic node to which the target edge points, determining the target sentence in at least one first sentence included in the second semantic node, then rewriting the current sentence based on the target sentence and the slot information collected by the first semantic node, and generating a complete sentence of the current sentence, for example, if the previous dialogue is "order an air ticket" and "please ask for departure", the current sentence of the current round of dialogue is "Beijing", in which case, the current sentence needs to be converted into the complete sentence, for example, "order an air ticket from Beijing".
Optionally, the step S401 may be specifically implemented by the following steps:
determining default information of the current sentence in slot information collected by the first semantic node under the condition that the current sentence is an incomplete sentence; and rewriting the current sentence according to at least one first sentence and the default information included in the second semantic node pointed by the target edge, and generating the complete sentence.
It can be understood that, under the condition that the current sentence is a non-complete sentence, determining the default information of the current sentence in the slot information collected by the first semantic node, wherein on the basis of the above example, the first semantic node is the semantic node corresponding to the previous dialog, the collected slot information is "strawberry", "ticket booking" and "departure", and the "ticket booking" and "departure" in the slot information are used as the default information of the current sentence. And then, rewriting the current sentence according to the target sentence and the default information to generate a complete sentence.
S402, determining a reply sentence of the complete sentence in at least one second sentence included in the second semantic node.
It can be appreciated that, after the complete sentence of the current sentence is generated based on the above S401, a reply template is selected from at least one second sentence included in the second semantic node to generate a reply sentence of the complete sentence, for example, on the above example, the generated reply sentence is "good, go? ", or" good, where is the destination? "complete the current round of dialogue, at this time, the current round of dialogue is" order a ticket from Beijing "and" good, where is the destination? ".
Optionally, in S402, determining a reply sentence of the complete sentence in at least one second sentence included in the second semantic node may specifically be implemented by the following steps:
if the complete sentence is an inquiry sentence, inquiring the complete sentence to generate an inquiry result; determining a target sentence matched with the complete sentence in at least one second sentence included in the second semantic node; and generating a reply statement of the complete statement according to the target statement and the query result.
It can be understood that if the current sentence or the complete sentence rewritten based on the current sentence is an inquiry sentence, for example, "the Beijing airport can be used as well", in this case, the question inquired by the complete sentence is inquired, an inquiry result is generated, for example, after the use condition of the Beijing airport is inquired, the Beijing airport is determined to be in a normal use state, then a reply sentence is generated according to the second sentence as a reply template and the inquiry result, for example, the generated reply sentence is "the Beijing airport is used normally, and a ticket from Beijing" is required to be ordered, so that the current round dialogue is completed, and the current round dialogue is "the Beijing airport can be used as well" the Beijing airport is required to be used normally.
According to the dialogue reply generation method provided by the embodiment of the disclosure, the key information of the prior dialogue is collected by using the slot position information, so that the relevance among multiple rounds of dialogues is fully considered, and the generation efficiency and accuracy of reply sentences are effectively improved.
Fig. 5 is a schematic structural diagram of a dialogue reply generation device according to an embodiment of the present disclosure. The dialogue reply generation device provided by the embodiment of the present disclosure may execute the processing flow provided by the embodiment of the dialogue reply generation method, as shown in fig. 5, where the dialogue reply generation device 500 includes an acquisition unit 501, a determination unit 502, and a generation unit 503, where:
an obtaining unit 501, configured to obtain a current sentence of a current round of dialogue;
a determining unit 502, configured to determine a first semantic node corresponding to the current round of dialogue among a plurality of semantic nodes included in a pre-constructed semantic space, and determine a target edge matched with a preset character and the current sentence in at least one skip edge connected with the first semantic node, where the semantic space further includes a plurality of skip edges, and each skip edge is used to connect two semantic nodes and carries a preset character;
and the generating unit 503 is configured to generate a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot information collected by the first semantic node, so as to complete the current round of dialogue.
Optionally, the determining unit 502 is configured to:
determining a plurality of historical semantic nodes from a plurality of semantic nodes included in the semantic space, wherein the plurality of historical semantic nodes comprise semantic nodes corresponding to the previous dialog;
the first semantic node is determined among the plurality of historical semantic nodes.
Optionally, the determining unit 502 is configured to:
sorting the plurality of history semantic nodes according to the time mark to obtain a plurality of sorted history semantic nodes;
determining a current historical semantic node from the plurality of ordered historical semantic nodes;
carrying out semantic matching on preset characters of each skip edge starting from the current historical semantic node and the current sentence, and calculating the matching degree;
if the matching degree is greater than or equal to a preset threshold value, determining the current historical semantic node as the first semantic node; or if the matching degree is smaller than the preset threshold value, continuing to determine the next historical semantic node until the first semantic node is determined or the plurality of historical semantic nodes are traversed.
Optionally, the plurality of history semantic nodes in the apparatus 500 include a third semantic node in an incomplete state, where the third semantic node in the incomplete state refers to any semantic node pointed to by all jump edges starting from the third semantic node is not a semantic node corresponding to a previous dialog.
Optionally, the determining unit 502 is configured to:
traversing the plurality of sequenced historical semantic nodes;
and if the first semantic node is not determined when traversing to the root semantic node, directly determining the third semantic node as the current historical semantic node.
Optionally, the semantic node in the apparatus 500 further includes a sentence pair, where the sentence pair includes at least one first sentence and at least one second sentence, and the semantics of the at least one first sentence are the same.
Optionally, the generating unit 503 is configured to:
rewriting the current sentence according to at least one first sentence included in a second semantic node pointed by the target edge and slot position information collected by the first semantic node, and generating a complete sentence of the current sentence;
and determining a reply statement of the complete statement in at least one second statement included in the second semantic node.
Optionally, the generating unit 503 is configured to:
if the complete sentence is an inquiry sentence, inquiring the complete sentence to generate an inquiry result;
determining a target sentence matched with the complete sentence in at least one second sentence included in the second semantic node;
And generating a reply statement of the complete statement according to the target statement and the query result.
Optionally, the generating unit 503 is configured to:
determining default information of the current sentence in slot information collected by the first semantic node under the condition that the current sentence is an incomplete sentence;
and rewriting the current sentence according to at least one first sentence and the default information included in the second semantic node pointed by the target edge, and generating the complete sentence.
The dialogue reply generation device of the embodiment shown in fig. 5 may be used to implement the technical solution of the above method embodiment, and its implementation principle and technical effects are similar, and will not be described herein again.
Fig. 6 is a schematic structural diagram of an electronic device provided in an embodiment of the present disclosure, where the electronic device may be a refrigerator, and a semantic space is associated with food material management of the refrigerator. Referring now in particular to fig. 6, a schematic diagram of an electronic device 600 suitable for use in implementing embodiments of the present disclosure is shown. The electronic device 600 in the embodiments of the present disclosure may include, but is not limited to, mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), wearable electronic devices, and the like, and fixed terminals such as digital TVs, desktop computers, smart home devices, and the like. The electronic device shown in fig. 6 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 6, the electronic device 600 may include a processing means (e.g., a central processor, a graphics processor, etc.) 601 that may perform various suitable actions and processes to implement the dialog reply generation method of the embodiments as described in the present disclosure according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage means 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the electronic apparatus 600 are also stored. The processing device 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
In general, the following devices may be connected to the I/O interface 605: input devices 606 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 607 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, and the like; storage 608 including, for example, magnetic tape, hard disk, etc.; and a communication device 609. The communication means 609 may allow the electronic device 600 to communicate with other devices wirelessly or by wire to exchange data. While fig. 6 shows an electronic device 600 having various means, it is to be understood that not all of the illustrated means are required to be implemented or provided. More or fewer devices may be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a non-transitory computer readable medium, the computer program comprising program code for performing the method shown in the flowchart, thereby implementing the dialog reply generation method as described above. In such an embodiment, the computer program may be downloaded and installed from a network via communication means 609, or from storage means 608, or from ROM 602. The above-described functions defined in the methods of the embodiments of the present disclosure are performed when the computer program is executed by the processing device 601.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples of the computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this disclosure, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
In some implementations, the clients, servers may communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol ), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), the internet (e.g., the internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.
The computer readable medium may be contained in the electronic device; or may exist alone without being incorporated into the electronic device.
Alternatively, the electronic device may perform other steps described in the above embodiments when the above one or more programs are executed by the electronic device.
Computer program code for carrying out operations of the present disclosure may be written in one or more programming languages, including, but not limited to, an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: a Field Programmable Gate Array (FPGA), an Application Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a system on a chip (SOC), a Complex Programmable Logic Device (CPLD), and the like.
In the context of this disclosure, a machine-readable medium may be a tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. The machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or gateway that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or gateway. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or gateway comprising the element.
The foregoing is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown and described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (11)

1. A method for generating a dialog reply, comprising:
acquiring a current sentence of a current round of dialogue;
determining a first semantic node corresponding to the current round of dialogue in a plurality of semantic nodes included in a pre-constructed semantic space, and determining a target edge matched with a preset character and the current sentence in at least one jump edge from the first semantic node, wherein the semantic space further comprises a plurality of jump edges, and each jump edge is used for connecting two semantic nodes and carrying the preset character;
generating a reply statement of the current statement based on the second semantic node pointed by the target edge and the slot information collected by the first semantic node, and completing the current round of dialogue, wherein the slot information comprises information collected from a previous round of dialogue, and the current round of dialogue and the previous round of dialogue belong to the same dialogue task.
2. The method of claim 1, wherein the determining a first semantic node corresponding to the current round of dialog among a plurality of semantic nodes included in a pre-constructed semantic space comprises:
determining a plurality of historical semantic nodes from a plurality of semantic nodes included in the semantic space, wherein the plurality of historical semantic nodes comprise semantic nodes corresponding to the previous dialog;
The first semantic node is determined among the plurality of historical semantic nodes.
3. The method of claim 2, wherein said determining the first semantic node among the plurality of historical semantic nodes comprises:
sorting the plurality of history semantic nodes according to the time mark to obtain a plurality of sorted history semantic nodes;
determining a current historical semantic node from the plurality of ordered historical semantic nodes;
carrying out semantic matching on preset characters of each skip edge starting from the current historical semantic node and the current sentence, and calculating the matching degree;
if the matching degree is greater than or equal to a preset threshold value, determining the current historical semantic node as the first semantic node; or if the matching degree is smaller than the preset threshold value, continuing to determine the next historical semantic node until the first semantic node is determined or the plurality of historical semantic nodes are traversed.
4. The method of claim 3, wherein the plurality of history semantic nodes further comprises a third semantic node in an incomplete state, the third semantic node in the incomplete state being that any semantic node pointed to by all jump edges from the third semantic node is not a semantic node corresponding to a previous round of dialog,
The determining the current historical semantic node from the sequenced plurality of historical semantic nodes comprises the following steps:
traversing the plurality of sequenced historical semantic nodes;
in the case that the plurality of history semantic nodes includes a root semantic node, if the first semantic node is not yet determined when traversing to the root semantic node, directly determining the third semantic node as the current history semantic node.
5. The method of claim 1, wherein the semantic node further comprises a statement pair comprising at least one first statement and at least one second statement, the semantics of the at least one first statement being the same,
the generating a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot information collected by the first semantic node comprises the following steps:
rewriting the current sentence according to at least one first sentence included in a second semantic node pointed by the target edge and slot position information collected by the first semantic node, and generating a complete sentence of the current sentence;
and determining a reply statement of the complete statement in at least one second statement included in the second semantic node.
6. The method of claim 5, wherein said determining a reply sentence to the complete sentence among at least one second sentence included in the second semantic node comprises:
if the complete sentence is an inquiry sentence, inquiring the complete sentence to generate an inquiry result;
determining a target sentence matched with the complete sentence in at least one second sentence included in the second semantic node;
and generating a reply statement of the complete statement according to the target statement and the query result.
7. The method of claim 5, wherein the rewriting the current sentence according to at least one first sentence included in the second semantic node pointed to by the target edge and the slot information collected by the first semantic node, and generating a complete sentence of the current sentence comprises:
determining default information of the current sentence in slot information collected by the first semantic node under the condition that the current sentence is an incomplete sentence;
and rewriting the current sentence according to at least one first sentence and the default information included in the second semantic node pointed by the target edge, and generating the complete sentence.
8. The method of claim 1, wherein the semantic space is associated with refrigerator food material management, the semantic space being constructed based on data samples corresponding to refrigerator food material management.
9. A dialog reply generation device, comprising:
the acquisition unit is used for acquiring the current sentence of the current round of dialogue;
the determining unit is used for determining a first semantic node corresponding to the current round of dialogue in a plurality of semantic nodes included in a pre-constructed semantic space, and determining a target edge matched with a preset character and the current sentence in at least one jump edge connected with the first semantic node, wherein the semantic space further comprises a plurality of jump edges, and each jump edge is used for connecting two semantic nodes and carries the preset character;
the generating unit is used for generating a reply sentence of the current sentence based on the second semantic node pointed by the target edge and the slot information collected by the first semantic node to complete the current round of dialogue, wherein the slot information comprises information collected from the previous round of dialogue, and the current round of dialogue and the previous round of dialogue belong to the same dialogue task.
10. An electronic device, comprising:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in the memory and configured to be executed by the processor to implement the dialog reply generation method of any of claims 1 to 8.
11. A computer readable storage medium having stored thereon a computer program, which when executed by a processor implements the steps of the dialog reply generation method of any of claims 1 to 8.
CN202311587740.5A 2023-11-24 2023-11-24 Dialogue reply generation method, device, equipment and storage medium Pending CN117609452A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311587740.5A CN117609452A (en) 2023-11-24 2023-11-24 Dialogue reply generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311587740.5A CN117609452A (en) 2023-11-24 2023-11-24 Dialogue reply generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117609452A true CN117609452A (en) 2024-02-27

Family

ID=89957494

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311587740.5A Pending CN117609452A (en) 2023-11-24 2023-11-24 Dialogue reply generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117609452A (en)

Similar Documents

Publication Publication Date Title
CN109145104B (en) Method and device for dialogue interaction
CN110096655B (en) Search result sorting method, device, equipment and storage medium
CN107943877B (en) Method and device for generating multimedia content to be played
CN110096584B (en) Response method and device
CN110619076B (en) Search term recommendation method and device, computer and storage medium
US20230259712A1 (en) Sound effect adding method and apparatus, storage medium, and electronic device
CN111340220B (en) Method and apparatus for training predictive models
CN110781658B (en) Resume analysis method, resume analysis device, electronic equipment and storage medium
CN115757400B (en) Data table processing method, device, electronic equipment and computer readable medium
CN111143523A (en) Intention confirming method and device
CN115455161A (en) Conversation processing method, conversation processing device, electronic equipment and storage medium
CN111738316A (en) Image classification method and device for zero sample learning and electronic equipment
CN112712795B (en) Labeling data determining method, labeling data determining device, labeling data determining medium and electronic equipment
EP3843090B1 (en) Method and apparatus for outputting analysis abnormality information in spoken language understanding
CN108667875B (en) Information updating method and device
KR102151322B1 (en) Information push method and device
CN116909539A (en) Visual programming method, device, equipment and storage medium
CN113360590B (en) Method and device for updating interest point information, electronic equipment and storage medium
CN112148847B (en) Voice information processing method and device
CN114141236B (en) Language model updating method and device, electronic equipment and storage medium
CN117609452A (en) Dialogue reply generation method, device, equipment and storage medium
CN112669816B (en) Model training method, voice recognition method, device, medium and equipment
CN113808582B (en) Speech recognition method, device, equipment and storage medium
CN114020896A (en) Intelligent question and answer method, system, electronic equipment and storage medium
CN113961769A (en) Session communication method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination