CN111930884A - Method and equipment for determining reply sentence and man-machine conversation system - Google Patents

Method and equipment for determining reply sentence and man-machine conversation system Download PDF

Info

Publication number
CN111930884A
CN111930884A CN202010630864.7A CN202010630864A CN111930884A CN 111930884 A CN111930884 A CN 111930884A CN 202010630864 A CN202010630864 A CN 202010630864A CN 111930884 A CN111930884 A CN 111930884A
Authority
CN
China
Prior art keywords
reply
sentences
template
statement
combined
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
CN202010630864.7A
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.)
Huawei Technologies Co Ltd
Original Assignee
Huawei Technologies 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 Huawei Technologies Co Ltd filed Critical Huawei Technologies Co Ltd
Priority to CN202010630864.7A priority Critical patent/CN111930884A/en
Publication of CN111930884A publication Critical patent/CN111930884A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3344Query execution using natural language analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/205Parsing
    • G06F40/211Syntactic parsing, e.g. based on context-free grammar [CFG] or unification grammars
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/20Natural language analysis
    • G06F40/279Recognition of textual entities
    • G06F40/289Phrasal analysis, e.g. finite state techniques or chunking

Abstract

The embodiment of the application discloses a method, equipment and a dialogue system for determining a reply sentence. The method can be used for a server in a man-machine conversation system. The method in the embodiment of the application comprises the following steps: after the query sentences are received, N reply template sentences are selected from the preset diversified reply template sentences according to the environment information from outside the man-machine conversation, and finally the target reply sentences are determined according to the N reply template sentences, so that the man-machine conversation system can sense the external environment information and increase the diversification of the reply sentences.

Description

Method and equipment for determining reply sentence and man-machine conversation system
Technical Field
The present application relates to the field of artificial intelligence technologies, and in particular, to a method, a device, and a dialog system for determining a reply statement.
Background
Artificial Intelligence (AI) is a theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and expand human Intelligence, perceive the environment, acquire knowledge and use the knowledge to obtain the best results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a manner similar to human intelligence. Artificial intelligence, namely, researching the design principle and implementation method of various intelligent machines, so that the machines have the functions of perception, reasoning and decision making
With the continuous development of artificial intelligence technology, natural language human-computer interaction systems, which enable human-computer interaction through natural language, become more and more important. Human-computer interaction through natural language requires a system capable of recognizing specific meanings of human natural language. Typically, systems identify the specific meaning of a sentence by employing key information extraction on the sentence in natural language.
At present, in the process of a man-machine conversation, after receiving a query statement of a user, a system selects a reply template statement matched with the query statement from a reply template statement set according to the query statement as a reply statement, and then feeds the reply statement back to the user.
Since the reply sentence is related to the query sentence only, the reply sentence is usually fixed for the same query sentence, and the reply sentence is less diverse.
Disclosure of Invention
The embodiment of the application provides a method for determining a reply sentence, and provides a device, a computer program product, a readable storage medium and a man-machine conversation system for implementing the method, so as to increase the diversity of the reply sentence.
In a first aspect, the present application provides a method for determining a reply statement, where the method is applicable to a server, and includes: and acquiring M reply template sentences corresponding to the query sentences in the man-machine conversation, wherein M is a positive integer, and the reply template sentences can comprise characters, numbers and slot positions. And acquiring environment information from outside the man-machine conversation, wherein the environment information is related to the man-machine conversation, so that the environment information can reflect the actual scene of the man-machine conversation. And selecting N reply template sentences from the M reply template sentences according to the environment information, wherein N is a positive integer. And determining the target reply statement according to the N reply template statements. Further, one of the N reply template statements may be used as a target reply statement, or a plurality of the N reply template statements may be combined into one target reply statement.
As the candidate N reply template sentences can be selected from the M reply template sentences according to the information from outside the man-machine conversation, diversified reply template sentences can be input, and the finally determined target reply sentences can be diversified and unfixed, so that the user experience can be improved.
In some implementations, the M reply template statements include a first reply template statement, and the first reply template statement is related to a first type of context information, where the first type of context information refers to one of information from outside the human-computer conversation.
Acquiring environmental information from outside the man-machine conversation includes: a first type of environment information corresponding to a man-machine conversation from outside the man-machine conversation is acquired.
In the implementation mode, N reply template sentences are selected according to the first type of environment information corresponding to the man-machine conversation.
In some implementations, the first type of context information has a preset value, the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to a case where the acquired first type of context information is equal to the preset value. The preset value can be set according to the actual needs of the user, and the form of the first applicable condition can be various.
Selecting N reply template statements from the M reply template statements according to the environment information comprises:
and taking the first reply template statement as one of the N reply template statements based on the acquired first type of environment information being equal to the preset value.
And based on the association of the first reply template statement and the first applicable condition, when the first type of environment information corresponding to the man-machine conversation is a preset value, taking the first reply template statement as one of the N selected reply template statements.
In some implementations, the first type of environmental information has a preset value;
the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value; the first reply template statement comprises a slot position, and the slot position is used for filling the first type of environment information.
Selecting N reply template statements from the M reply template statements according to the environment information comprises: based on the obtained first-class environmental information being equal to a preset value, filling the obtained first-class environmental information into the slot position; and filling the slot position with the first reply template statement of the acquired first type of environment information as one of the N reply template statements.
In some implementation manners, the first reply template statement includes a slot position, and the first reply template statement includes a slot position, where the slot position is used to fill the first type of environment information corresponding to the human-computer conversation; selecting N reply template statements from the M reply template statements according to the environment information comprises: filling the obtained first type of environment information into the slot position; and filling the slot position with the first reply template statement of the acquired first type of environment information as one of the N reply template statements.
In the implementation mode, whether the first type of environment information corresponding to the man-machine conversation is a preset value or not does not need to be judged, and the first reply template sentence can be directly used as one of the N reply template sentences after the first type of environment information corresponding to the man-machine conversation is obtained.
In some implementations, determining the target reply statement from the N reply template statements includes: acquiring P combined sentences in N reply template sentences, wherein N is greater than 1, and P is an integer greater than 1; obtaining Q combined reply sentences according to the P combined sentences, wherein each of the Q combined reply sentences is obtained by combining at least two combined sentences in the P combined sentences, and Q is a positive integer; and selecting one statement from the Q combined reply statements and the N reply template statements as a target reply statement.
And combining the P combined sentences to obtain Q combined reply sentences, and then selecting one sentence from the Q combined reply sentences and the N candidate reply sentences as a target reply sentence, so that the target reply sentence can be one of the Q combined reply sentences or one of the N reply template sentences, and the diversity of the reply sentences is increased.
In some implementations, selecting one of the Q combined reply statements and the N reply template statements as the target reply statement includes: and retrieving K test sentences corresponding to the first combined reply sentence from the corpus according to the retrieval model. Corpora usually contain a plurality of corpora, which are also called free text, and can be words, sentences, fragments, articles and any combination thereof. The search model may be a TF-IDF (term-inverse document frequency) technology-based search model for outputting a test statement that is more correlated than a first threshold with a first combined reply statement, the first combined reply statement being any one of Q combined reply statements.
And calculating the similarity between the first combined reply statement and each test statement in the K test statements according to a pre-training model, wherein the pre-training model is used for calculating the similarity between the first combined reply statement and the test statements, and the similarity can be represented by the distance between vectors. Taking the first combined reply sentence as a candidate combined reply sentence based on the fact that the maximum similarity in the similarities of the first combined reply sentence and the K test sentences is larger than a second threshold; and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence.
In the implementation manner, based on the fact that the maximum similarity of the similarities of the first combined reply statement and the K test statements is greater than the second threshold, the first combined reply statement is used as a candidate combined reply statement, so that the candidate combined reply statement is guaranteed to have no grammar and other related problems, namely, the availability of the candidate combined reply statement is guaranteed.
In some implementations, selecting one of the candidate combined reply statements and the N reply template statements as the target reply statement includes: determining the probability of the candidate combined reply sentences and the probability of the N reply template sentences which are respectively selected, wherein the probability of the selection corresponding to any one candidate combined reply sentence is greater than the probability of the selection corresponding to any one reply template sentence; and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence based on the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
Compared with reply template sentences, the candidate combined reply sentences have richer contents and can improve the intelligence of man-machine conversation, so that in the embodiment of the application, the probability of selecting any one candidate combined reply sentence is greater than that of selecting any one reply template sentence, and the probability of selecting the candidate combined reply sentence as the target reply sentence is greater than that of selecting the reply template sentence as the reply sentence.
In some implementations, determining the probability that the candidate combined reply statement and the N reply template statements are selected respectively includes: determining the score of each candidate combined reply sentence according to the maximum similarity in the similarities of the candidate combined reply sentences and the corresponding K test sentences; taking a preset score as the score of each candidate reply sentence in the N candidate reply sentences, wherein the preset score is smaller than the score of each candidate combined reply sentence; and normalizing the score of each candidate combined reply sentence and the score of each reply template sentence in the N reply template sentences to obtain the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
In the implementation mode, the candidate combined reply sentences and the N reply template sentences are scored, and then the probability that the candidate combined reply sentences and the N reply template sentences are selected respectively is determined according to the scores, so that the probability of selecting the candidate combined reply sentences as the reply sentences is greater than the probability of selecting the reply template sentences as the reply sentences.
In a second aspect, the present application provides an apparatus for determining a reply sentence, including:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring M reply template sentences corresponding to query sentences in the man-machine conversation, and M is a positive integer;
the second acquisition unit is used for acquiring environmental information from outside the man-machine conversation, and the environmental information is related to the man-machine conversation;
the selection unit is used for selecting N reply template sentences from the M reply template sentences according to the environment information, wherein N is a positive integer;
and the determining unit is used for determining the target reply statement according to the N reply template statements.
In some implementations, the M reply template statements include a first reply template statement, the first reply template statement being related to a first type of context information. And the second acquisition unit is used for acquiring the first type of environment information from outside the man-machine conversation.
In some implementations, the first type of environmental information has a preset value; the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value; and the selecting unit is used for taking the first reply template statement as one of the N reply template statements based on the fact that the acquired first type of environment information is equal to a preset value.
In some implementations, the first type of environmental information has a preset value; the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value; the first reply template statement comprises a slot position, and the slot position is used for filling the first type of environment information.
The device also comprises a filling unit used for filling the obtained first type environment information into the slot position based on the obtained first type environment information being equal to a preset value; and the selecting unit is further used for filling the slot position with the first reply template statement of the acquired first type of environment information as one of the N reply template statements.
In some implementation manners, the first reply template statement includes a slot position, and the slot position is used for filling first-class environmental information corresponding to the man-machine conversation; the device also comprises a filling unit used for filling the obtained first type environment information into the slot position; the selection unit is further configured to fill the slot with a first reply template statement of the acquired first type of environment information as one of the N reply template statements.
In some implementations, the determining unit is configured to obtain P combined statements in N reply template statements, where N is greater than 1, and P is an integer greater than 1; obtaining Q combined reply sentences according to the P combined sentences, wherein each of the Q combined reply sentences is obtained by combining at least two combined sentences in the P combined sentences, and Q is a positive integer; and selecting one statement from the Q combined reply statements and the N reply template statements as a target reply statement.
In some implementations, the determining unit is configured to retrieve K test statements corresponding to a first combined reply statement from a corpus according to a retrieval model, where the retrieval model is configured to output the test statement whose degree of correlation with the first combined reply statement is greater than a first threshold, and the first combined reply statement is any one of Q combined reply statements; calculating the similarity between the first combined reply statement and each test statement in the K test statements according to a pre-training model, wherein the pre-training model is used for calculating the similarity between the first combined reply statement and the test statements; taking the first combined reply sentence as a candidate combined reply sentence based on the fact that the maximum similarity in the similarities of the first combined reply sentence and the K test sentences is larger than a second threshold; and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence.
In some implementations, the determining unit is configured to determine respective selected probabilities of the candidate combined reply sentences and the N reply template sentences, where the selected probability corresponding to any one of the candidate combined reply sentences is greater than the selected probability corresponding to any one of the reply template sentences; and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence based on the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
In some implementations, the determining unit is configured to determine a score of each candidate combined reply sentence according to a maximum similarity among similarities of the candidate combined reply sentences and the corresponding K test sentences; taking a preset score as the score of each candidate reply sentence in the N candidate reply sentences, wherein the preset score is smaller than the score of each candidate combined reply sentence; and normalizing the score of each candidate combined reply sentence and the score of each reply template sentence in the N reply template sentences to obtain the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
In a third aspect, the present application provides a server, comprising: at least one processor and a memory, the memory storing computer-executable instructions executable on the processor, the server performing the method provided by any one of the first aspect when the computer-executable instructions are executed by the processor.
In a fourth aspect, the present application provides a chip or a chip system, the chip or chip system comprising at least one processor and a communication interface, the communication interface and the at least one processor being interconnected by a line, the at least one processor being configured to execute a computer program or instructions to perform the method as provided in any one of the first aspect.
In a fifth aspect, the present application provides a computer storage medium for storing a computer program which, when executed by one or more processors, implements the method provided by any one of the first aspects.
In a sixth aspect, the present application provides a computer program product for storing a computer program that, when executed by one or more processors, performs the method provided by any one of the first aspects.
In a seventh aspect, the present application provides a human-machine interaction system, which includes a terminal device and a server.
The terminal device is used for sending a query statement to the server, and the server is used for executing the method provided by any one of the first aspect.
According to the technical scheme, the embodiment of the application has the following advantages:
the system acquires environment information from outside the man-machine conversation, wherein the environment information is related to the man-machine conversation, and then selects N reply template sentences from the M reply template sentences according to the environment information, wherein N is a positive integer, so that the system can sense external environment information; and because N reply template sentences can be selected according to environment information from outside the man-machine conversation, diversified reply template sentences can be configured in advance, then M reply template sentences corresponding to the query sentences can also be diversified, and then different reply template sentences can be selected based on different information from outside the man-machine conversation, so that the finally determined target reply sentences are not fixed, the diversity of the target reply sentences is better, and the user experience in the man-machine conversation process can be improved.
Drawings
FIG. 1 is a schematic diagram of an architecture of a human-computer interaction system according to an embodiment of the present application;
FIG. 2 is an interface diagram of a new intention in an embodiment of the present application;
FIG. 3 is a schematic interface diagram of a configuration slot in an embodiment of the present application;
FIG. 4 is a schematic diagram of a first embodiment of determining a reply statement in an embodiment of the present application;
FIG. 5 is a diagram of a second embodiment of determining a reply statement in the embodiment of the present application;
FIG. 6 is a diagram of a first embodiment of selecting a reply statement in an embodiment of the present application;
FIG. 7 is a diagram of a second embodiment of selecting a reply statement in the embodiment of the present application;
FIG. 8 is a schematic diagram of an embodiment of determining a probability that a sentence is selected in an embodiment of the present application;
FIG. 9 is a block diagram illustrating an apparatus for determining a reply sentence according to an embodiment of the present application;
FIG. 10 is a schematic structural diagram of a server in an embodiment of the present application;
fig. 11 is a schematic structural diagram of a server man-machine conversation system in an embodiment of the present application.
Detailed Description
The embodiment of the application provides a method, equipment and a man-machine conversation system for determining reply sentences, which are used for increasing the diversity of the reply sentences so as to improve the experience of a user in the man-machine conversation process.
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The method of the embodiment of the application can be applied to the human-computer interaction system shown in FIG. 1. The man-machine interaction system comprises user equipment, data entry equipment and data processing equipment.
The user equipment comprises a user, a mobile phone, a personal computer or an intelligent terminal such as an information processing center. The user equipment is an initiating end of a human-computer conversation and is used as an initiator of requests such as language question answering or query, and usually a user initiates the requests through the user equipment. The user equipment in fig. 1 includes a mobile phone, a tablet computer, and a notebook computer.
The data entry device can be a terminal device such as a computer and the like, and is used for entering relevant data and relevant configuration of the man-machine conversation into the data processing device.
The data processing device may be a device or a server having a data processing function, such as a cloud server, a network server, an application server, and a management server. The data processing equipment receives inquiry sentences such as inquiry sentences/voice/text and the like from the intelligent terminal through the interactive interface, and then performs language data processing in the modes of machine learning, deep learning, searching, reasoning, decision making and the like through a memory for storing data and a processor link for data processing. The memory may be a generic term that includes databases that store historical data locally, either on the data processing device or on other network servers.
Taking the human-computer interaction system shown in fig. 1 as an example, in order to increase diversity of reply statements, in the embodiment of the present application, diversified reply template statements are entered into a database corresponding to a data processing device through a data entry device, so that the data processing device can screen reply template statements matched with query statements from the database after receiving a query request from an intelligent terminal, then further screen according to information from outside of a human-computer conversation, and determine target reply statements according to the screened reply template statements. Because the input reply template sentences are diversified, different candidate reply sentences can be selected based on different information from outside of the man-machine conversation, the finally determined target reply sentence is not fixed, the diversity of the target reply sentence is better, and the user experience in the man-machine conversation process is improved.
For ease of understanding, the methods of the embodiments of the present application are described in detail below.
It can be understood that the method of the embodiment of the application comprises two processes of reply template statement entry and determination of reply statement. The process of reply template statement entry is described first below.
Reply template statement entry process
And the entry personnel operates on the data entry equipment and enters diversified reply template sentences into the data processing equipment.
There are various methods for entering the reply template statement. As a practical way, diversified reply template statements may be classified into a data processing device.
In particular, the entry personnel may establish a plurality of intent templates on the data entry device, each intent template including a corresponding set of query templates and a set of reply templates, each set of query templates including one or more query template statements, each set of reply templates including one or more reply template statements. In the man-machine conversation, if the query sentence of the user is any query template sentence in an intention template, any reply template sentence in the same intention template can be adopted as a reply sentence for replying.
In embodiments of the present application, each intent template represents a type of reply template statement. The name of the intention template can be set as required, and can be, for example, travel, weather, location, study, and any other name. As shown in fig. 2, the intention template includes a set of query templates including three query template statements of "hello", "hi", and "hello", and a set of reply templates including four reply template statements of "hello", "_ good", and "today's weather is also good".
The reply template statement may include a word, a number, and a slot, and as shown in fig. 2, a reply template statement "_" in the reply template statement "_ good" indicates a slot, and the slot is used for filling information. For example, after filling "am" in the slot, the reply template statement becomes "In the morningGood ".
It will be appreciated that in addition to entering the reply template statement, the relevant configuration of the reply template statement may also be entered. The associated configuration may include a variety.
For example, the relevant configuration of the reply template statement may include a combined reply message, as shown in FIG. 2, that includes an indication of whether or not to combine in the intent template and the order of the combination. Wherein the indication of whether to combine in the intent template indicates whether multiple reply template statements in the intent template can be combined into one reply statement; the combination order refers to the maximum number of reply template statements that can be combined in the same intent template. Taking fig. 2 as an example, if the combination order is 3, it indicates that one reply template sentence may be used as a reply sentence, 2 reply template sentences may be combined to be used as a target reply sentence, or 3 reply template sentences may be combined to be used as a target reply sentence; if the combination order is 2, it means that one reply template sentence can be combined to be used as a target reply sentence, 2 reply template sentences can be combined to be used as a target reply sentence, but 3 or more than 3 reply template sentences can not be combined to be used as a target reply sentence.
For example, the relevant configuration of the reply template statements may include a pre-trained model for verifying whether the combined statements are available. In fig. 2, the pre-trained models include a first pre-trained model, a second pre-trained model, and a third pre-trained model.
For example, the relevant configuration of the reply template statement may further include an applicable condition of the reply template statement, where the applicable condition may be represented in various ways, and this is not specifically limited in this embodiment of the present application. As shown in fig. 2, the applicable condition corresponding to the reply template statement "hello" is automatic analysis, which can be understood as being applicable under any condition; when the applicable conditions are automatically analyzed, the user does not need to enter specific applicable conditions, so that the entry process can be simplified, and the entry efficiency is improved; similarly, the applicable condition corresponding to one of the reply template statements "_ good" is also automatically analyzed, which means that "_ good" is applicable under any condition. The other reply template statement "_ good" corresponds to the applicable condition of "day long type is afternoon", i.e. it means that "_ good" is applicable in the case of day long type being afternoon. The corresponding applicable condition of the reply template sentence 'the weather is also good today' is 'weather is clear', namely, the reply template sentence 'the weather is also good today' is applicable under the condition of clear weather.
It will be appreciated that, since the reply template statement includes a slot, the relevant configuration of the reply template statement may also include parameters of the slot. Specifically, the parameters of the slot may include the type of the slot and the name of the slot.
As shown in fig. 3, the slot types may include a conditional slot and a normal slot, where the normal slot is used to fill information obtained from context information in the human-computer conversation, and the conditional slot is used to fill environment information obtained from outside the human-computer conversation. The condition slot position may further include a system internal condition slot position and an external resource condition slot position, where the system internal condition slot position is used to fill environment information outside the human-computer conversation acquired from the inside of the data processing device, and may include, for example, system time and system date; the external resource condition slot is used to fill in information outside the human-machine conversation acquired from a resource outside the data processing apparatus, and may include, for example, a location where the human-machine conversation occurs, weather at the location where the human-machine conversation occurs, humidity at the location where the human-machine conversation occurs, and temperature at the location where the human-machine conversation occurs.
The name of the slot may be set according to actual needs, and in the embodiment of the present application, the name of the slot may be set as an information type filled in the slot, for example, the name of the slot may be a transportation type and a weather type. When the slot position name is the traffic mode type, the slot position can be filled with a specific traffic mode; when the slot name is weather type, the slot may be filled with a specific weather.
Taking the slot shown in fig. 3 as an example, the slot is a conditional slot and belongs to an external resource conditional slot in the conditional slot, and the name of the slot is a weather type.
The process of entering the reply template sentence is described above, and the process of determining the reply sentence is described below based on the above-described entry of the reply template sentence.
Procedure for determining reply statements
Referring to fig. 4, a diagram of a first embodiment of determining a reply statement in an embodiment of the present application is shown. As shown in fig. 4, an embodiment of the present application provides an embodiment of a method for determining a reply statement, which may be applied to the data processing apparatus shown in fig. 1, and includes:
step 101, obtaining M reply template sentences corresponding to query sentences in the man-machine conversation, wherein M is a positive integer.
In the man-machine conversation process, the data processing equipment receives a query sentence from the intelligent terminal, the form of the query sentence is not particularly limited in the embodiment of the application, for example, the query sentence can be formed by one word and can be formed by one word; the query sentence may include one sentence or a plurality of sentences.
Upon receiving the query statement, the data processing device retrieves from the database a reply template statement for answering the query statement.
It should be noted that there are various methods for obtaining M reply template statements corresponding to a query statement, and this is not specifically limited in the embodiment of the present application.
For example, based on the database containing a plurality of intent templates, each intent template contains a set of query templates and a set of reply templates. The data processing device may first calculate a similarity between the query statement and a query template statement in each intention template, and if the similarity between the query statement and one query template statement in a certain intention template is greater than a preset first similarity, may list all reply template statements in the intention template into M reply template statements corresponding to the query statement.
Thus, the M reply template statements may be from the same intent template or from different intent templates.
Step 102, obtaining environment information from outside of the man-machine conversation, wherein the environment information is related to the man-machine conversation.
The information in the human-computer conversation may be understood as context information in the human-computer conversation, and the environment information from outside the human-computer conversation refers to information in the non-human-computer conversation.
For example, the environment information from outside the human-machine conversation may include environment information outside the human-machine conversation acquired from inside the data processing apparatus, and may include, for example, a system time (i.e., a time when the human-machine conversation occurs) and a system date (i.e., a date when the human-machine conversation occurs); the environmental information outside the human-machine conversation acquired from the resource outside the data processing apparatus may include, for example, a position where the human-machine conversation occurs, weather at the position where the human-machine conversation occurs, humidity at the position where the human-machine conversation occurs, and temperature at the position where the human-machine conversation occurs.
It should be noted that, based on the environment information related to the human-computer conversation, the environment information may reflect an actual scene of the human-computer conversation, for example, the environment information may be a position where the human-computer conversation occurs and weather at the position where the human-computer conversation occurs. There are various situations in which the environment information is related to the man-machine conversation, and this is not particularly limited in the embodiment of the present application.
There are various methods for acquiring the environment information from outside the human-computer conversation, which are not specifically limited in this application, and hereinafter, the method for acquiring the environment information from outside the human-computer conversation will be described in detail.
And 103, selecting N reply template sentences from the M reply template sentences according to the environment information, wherein N is a positive integer.
It should be noted that, since the environment information is related to the human-computer interaction, the environment information may be used as a filtering condition for the reply template statement, for example, if some reply template statements may contradict the environment information, the reply template statement cannot be used as one of the N reply template statements.
For example, it is assumed that the environmental information from outside the man-machine conversation includes "weather today is rain", and the reply template sentence "weather today is also good" cannot be one of the N reply template sentences; it is still assumed that the environmental information from outside the man-machine conversation includes "weather today is rain", and the reply template sentence "go to playground to play basketball" cannot be one of the N reply template sentences.
Therefore, N reply template statements may be selected from the M reply template statements based on the environment information, and there are various methods for selecting the N reply template statements, which are not specifically limited in this embodiment of the application, and the method for selecting the N reply template statements will be described in detail hereinafter.
And step 104, determining a target reply statement according to the N reply template statements.
There are various methods for determining the target reply statement according to the N reply template statements, for example, one of the N reply template statements may be directly used as the target reply statement, multiple ones of the N reply template statements may be combined to obtain the target reply statement, and one of the N reply template statements or the combined statements may be further optimized to obtain the target reply statement.
Hereinafter, a method for determining a reply statement from N reply template statements will be described in detail with reference to the drawings.
In the embodiment of the present application, taking the intention template shown in fig. 2 as an example, one query template statement is "hello", since M reply template statements can be selected according to environment information from outside the man-machine conversation, the reply template statement may include "hello" and may also include "today is good weather". When the environmental information from outside the man-machine conversation is to include "weather today is rain", it is possible to select "hello" as one of the N reply template sentences, and not select "weather today is also good" as one of the N reply template sentences. When the environment information from outside the human-computer conversation includes "weather today is sunny", then "weather today is also good" may be selected as one of the N reply template sentences.
If the environment information from outside the man-machine conversation cannot be acquired in the man-machine conversation process, the M reply template sentences cannot be selected according to the environment information from outside the man-machine conversation; based on the foregoing description, if the actual weather of the location where the man-machine conversation occurs is rain, then "the weather is also good today" cannot be taken as one of the N reply template sentences, so in order to avoid that the selected candidate reply sentence is not suitable for the actual scene of the man-machine conversation, then "the weather is also good today" cannot be taken as the reply template sentence, and only the sentence, which is suitable for any scene of the man-machine conversation, of "hello" can be taken as the reply template sentence, thereby limiting the diversification of the entered reply template sentence, and also making the finally determined target reply sentence lack of diversification.
Therefore, in the embodiment of the application, the data processing device can sense the change of the environment information from outside the man-machine conversation, and then select N reply template sentences from M reply template sentences according to the environment information from outside the man-machine conversation; because N reply template sentences can be selected from M reply template sentences according to the environment information from outside the man-machine conversation, diversified reply template sentences can be input in the input process of the reply template sentences, the selected candidate reply sentences are diversified, the finally determined reply sentences can be diversified and unfixed, and the user experience can be improved.
As can be seen from the above description, there are many contents of the environment information from outside the human-computer conversation, and as one possibility, the environment information from outside the human-computer conversation is related to the reply template sentence.
Specifically, in another embodiment of the method for determining a reply statement provided in this embodiment of the application, the M reply template statements include a first reply template statement, and the first reply template statement is related to a first type of environment information corresponding to the human-computer conversation.
The first type of environment information refers to one of environment information from outside of the man-machine conversation.
Based on the correlation between the first reply template statement and the first type of environment information corresponding to the man-machine conversation, acquiring the environment information from outside the man-machine conversation comprises the following steps: a first type of environmental information from outside the human-machine conversation is obtained.
The above is further explained by an example.
If the first reply template statement is related to the weather of the position where the man-machine conversation occurs, the first type of environmental information is the weather of the position where the man-machine conversation occurs; based on this, the data processing device may obtain weather of the position where the man-machine conversation occurs, and the actual value may be clear, rain, or cloudy.
If the first reply template statement is related to the time of the human-computer conversation, the first type of environmental information is the time of the human-computer conversation; based on this, the data processing device will obtain the time when the man-machine conversation occurs, and the actual value can be morning, afternoon or evening.
In this embodiment of the present application, there are multiple ways to indicate that the first reply template statement is related to the first type of environment information corresponding to the human-computer conversation, which is not specifically limited in this embodiment of the present application.
Two ways of indicating that the first reply template statement is related to the first type of context information corresponding to the human-computer dialog are described below.
Based on the foregoing description, in the process of inputting the reply template statement, in addition to inputting the first reply template statement, the applicable condition of the first reply template statement may also be input; based on this, as an achievable way, the first type of environment information has a preset value, the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to a case where the acquired first type of information is equal to the preset value.
The preset value can be set according to the actual needs of a user; for example, if the first type of environmental information is weather of a location where a human-computer conversation occurs, the preset value may be clear; assuming that the first type of environment information is the time when the human-computer conversation occurs, the preset value may be in the morning.
The form of the first applicable condition may be various, for example, as shown in fig. 2, it may be indicated that the first reply template sentence is applicable to a case where the weather of the position where the man-machine conversation occurs is fine by the first applicable condition "weather is fine"; the first applicable condition "day long type is afternoon" may also be used to indicate that the first reply template sentence is applicable to the case where the day long type corresponding to the time when the human-computer conversation occurs is afternoon.
Based on the first applicable condition, selecting N reply template statements from the M reply template statements according to the environment information includes:
and taking the first reply template statement as one of the N reply template statements based on the acquired first type of environment information being equal to the preset value.
In the embodiment of the application, a first applicable condition is adopted to represent that a first reply template statement is related to a first type of environment information corresponding to a man-machine conversation; based on the association between the first reply template statement and the first applicable condition, when the first type of environment information corresponding to the man-machine conversation is a preset value in the first applicable condition, the first reply template statement is used as one of the N reply template statements.
As can be seen from the foregoing description, the entered reply template statement may include a slot, and during the entry of the reply template statement, a parameter of the slot is also entered, for example, the name of the slot may be used to indicate the type of information filled in the slot.
Therefore, in another embodiment of determining a reply statement provided in this application embodiment, the first reply template statement includes a slot, and the slot is used to fill the first type of environment information corresponding to the human-computer conversation.
It should be noted that the slot position can be represented by a parameter of the slot position to fill the first type of environment information corresponding to the human-computer conversation; illustratively, the slot may be represented by its name for populating the first type of context information corresponding to the human-machine conversation. For example, the slot name "transportation type" may be used to indicate that the slot is used to fill the transportation that exists at the location where the human-machine conversation occurs; the slot name "weather type" may be used to indicate the weather at the location where the fill man-machine conversation occurs.
The first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value;
selecting N reply template statements from the M reply template statements according to the environment information comprises:
based on the obtained first-class environmental information being equal to a preset value, filling the obtained first-class environmental information into the slot position;
and filling the slot position with the first reply template statement of the acquired first type of environment information as one of the N reply template statements.
As shown in fig. 2, it is assumed that the first reply template sentence is "_ good" in fig. 2, and the first applicable condition is that "the day length is the afternoon" in fig. 2, which means that the first reply template sentence "_ good" is applicable when the day length to which the time of the occurrence of the man-machine conversation belongs is the afternoon, that is, the first type of environment information is the day length to which the time of the occurrence of the man-machine conversation belongs, and the reply template sentence includes a slot, which is assumed to be used for filling the day length corresponding to the time of the occurrence of the man-machine conversation.
If the day length of the time of the man-machine conversation is afternoon, the slot position can be filled with afternoon, and the first reply template sentence becomes'In the afternoonGood ".
In the embodiment of the application, besides the first applicable condition is adopted to indicate that the first reply template sentence is related to the first type of environment information corresponding to the human-computer conversation, the slot position is also adopted to indicate that the first reply template sentence is related to the first type of environment information corresponding to the human-computer conversation.
In another embodiment of determining the reply statement provided in this embodiment of the present application, the slot may be only used to indicate that the first reply template statement is related to the first type of environment information corresponding to the human-computer conversation.
Specifically, the first reply template statement includes a slot, and the slot is used for filling the first type of environment information corresponding to the human-computer conversation.
Since the slot has been described in the foregoing embodiments, the slot in the embodiments of the present application can be understood by referring to the related description of the slot in the foregoing embodiments.
Selecting N reply template statements from the M reply template statements according to the environment information comprises:
filling the obtained first type of environment information into the slot position;
and filling the slot position with the first reply template statement of the acquired first type of environment information as one of the N reply template statements.
It can be understood that, different from the foregoing embodiment, in the embodiment of the present application, it is not necessary to determine whether the first type of environment information corresponding to the human-computer conversation is a preset value, and after the first type of environment information corresponding to the human-computer conversation is obtained, the first reply template sentence may be directly used as one of the N reply template sentences.
As shown in fig. 2, assuming that the first reply template statement is "_ good" in fig. 2, and the corresponding applicable condition is automatic analysis, since automatic analysis can be understood as being applicable under any condition, it may be considered that the applicable condition is not adopted to indicate that the first reply template statement "_ good" is related to the first type of context information corresponding to the human-computer conversation, and only the slot in the first reply template statement "_ good" indicates that the first reply template statement "_ good" is related to the first type of context information corresponding to the human-computer conversation.
It can be understood that, if the slot in the first reply template statement is used to fill the date length to which the time of the man-machine conversation occurs, that is, the date length to which the first type of environment information belongs is the date length to which the time of the man-machine conversation occurs, and the date to which the time of the man-machine conversation occurs belongsThe long form is morning, the morning can be filled into the slot, and the first reply template statement becomes "In the morningGood ".
In the foregoing embodiment, the data processing device selects N reply template statements from M reply template statements by sensing environmental information from outside the human-computer conversation, so that diversification of the N reply template statements can be increased, and diversification of the determined target reply statement can be increased.
In addition, a plurality of reply template sentences can be combined to be used as reply sentences so as to increase the diversity of the reply sentences.
Specifically, based on the foregoing embodiments, in another embodiment of determining a reply statement provided in this application embodiment, as shown in fig. 5, determining a target reply statement according to N candidate reply statements may include:
step 201, P combined statements in N reply template statements are obtained, where N is greater than 1, and P is an integer greater than 1.
It should be noted that the combined statement may be determined according to the aforementioned combined reply information, for example, P reply template statements in the N reply template statements are associated with the combined reply information, and the combined reply information indicates that at least two reply template statements in the P reply template statements may be combined into one combined reply statement, and then the P reply template statements may be taken as P combined statements.
It should be noted that, the form of the combined reply message may be various, and this is not specifically limited in the embodiment of the present application; based on the foregoing process of entering the reply template statement, the combined reply information may include an indication of whether or not to combine in each intent template and the order of the combination.
And, the indication of whether to combine and the combination order both correspond to the intent template, i.e., the indication of whether to combine is used to indicate whether the reply template statements in the corresponding intent template can be combined, the combination order refers to the maximum number of reply template statements that can be combined in the corresponding intent template.
Therefore, in the embodiment of the present application, the combined reply information may indicate that multiple sets of reply template statements in the P reply template statements may be combined individually; specifically, each set of reply template statements includes a plurality of reply template statements, and some or all of the reply template statements in each set of reply template statements may be combined into one combined reply statement.
Based on the process of inputting the reply template sentence, at least two combined sentences belonging to the same intention template in the P combined sentences can be combined to obtain a combined reply sentence; therefore, the combined sentences corresponding to the two combined reply sentences can belong to the same intention template or different intention templates.
Each combined reply statement may be obtained by combining two combined statements, may be obtained by combining three combined statements, or may be obtained by combining three or more combined statements, which is not specifically limited in this embodiment of the present application.
For example, assume that a P combined statement includes: "hello", "morning good" and "today's weather is also very good"; the Q combined reply sentences may include "hello, morning good", "hello, weather is good today", "morning good, weather is good today" and "hello, morning good, weather is good today".
Step 202, obtaining Q combined reply statements according to the P combined statements, each of the Q combined reply statements being obtained by combining at least two combined statements in the P combined statements, Q being a positive integer.
Step 203, select one sentence from the Q combined reply sentences and the N reply template sentences as the target reply sentence.
It is understood that, in order to increase the diversity of the reply sentences, the reply sentences are selected from the Q combined reply sentences and the N reply template sentences, i.e., the reply sentences may be combined reply sentences or non-combined reply sentences.
It should be noted that there are various methods for selecting a target reply statement from Q combined reply statements and N reply template statements, which is not specifically limited in the embodiment of the present application; for example, the selection may be random, or the combination reply sentence may be preferentially selected. A method for selecting a target reply statement from the Q combined reply statements and the N reply template statements will be described in detail with reference to FIG. 6. In the embodiment of the present application, candidate reply statements in P combined statements are combined to obtain Q combined reply statements, and then one statement is selected from the Q combined reply statements and N reply template statements as a target reply statement, so that the reply statement may be one of the Q combined reply statements or one of the N reply template statements, thereby increasing the diversity of the reply statements.
Based on the above description, there are various methods for selecting a reply sentence from Q combined reply sentences and N reply template sentences, and one of the methods is described below.
Since the combined reply sentence is obtained by automatically combining a plurality of candidate reply sentences by the data processing device, the combined reply sentence may have a grammatical problem, that is, the combined reply sentence does not conform to the grammatical habit of the user, and in addition, the combined reply sentence may have other problems; for this reason, the embodiment of the present application detects the combined reply sentence, and then determines the reply sentence according to the detected combined reply sentence.
Specifically, as shown in fig. 6, in another embodiment of determining a reply sentence provided by the present application, selecting one sentence from Q combined reply sentences and N reply template sentences as the target reply sentence includes:
step 301, K test sentences corresponding to the first combined reply sentence are retrieved from the corpus according to a retrieval model, the retrieval model is used for outputting the test sentences of which the degree of correlation with the first combined reply sentence is greater than a first threshold, and the first combined reply sentence is any one of Q combined reply sentences.
The corpus usually contains a plurality of corpora, which are also called free texts, and can be words, sentences, fragments, articles and any combination thereof, wherein each test sentence is a corpus of corpora.
It should be noted that the search model may be understood as a model for constructing a search similar statement based on the statements of the first combined reply statement, where the search model may be various, and this is not specifically limited in this embodiment of the present application; for example, the search model may be a search model based on a TF-IDF (Term-Inverse Document Frequency) technique, where TF is Term Frequency (Term Frequency) and IDF is Inverse text Frequency index (Inverse Document Frequency).
The first threshold may be set according to actual needs, which is not specifically limited in this embodiment of the application.
In the embodiment of the application, the test statement is used as a comparison statement of the combined reply statement to test whether the combined reply statement has grammar or not.
For example, assuming that the first combined reply sentence is "hello, today's weather is also good", the K test sentences may include "hello, today's weather is not bad", "hello, today's weather is good", and "hello, today's weather is really good".
Step 302, calculating the similarity between the first combined reply statement and each of the K test statements according to a pre-training model, where the pre-training model is used to calculate the similarity between the first combined reply statement and the test statements.
The pre-training model may include multiple types, for example, may be a calculation model based on a neural network, and specifically, the first combined reply statement and the test statement may both be represented as vectors, and then, by calculating a distance between the vectors, a similarity between the first combined reply statement and each test statement may be calculated.
The pre-training model is a mature technology, and the embodiment of the present application is not specifically limited herein.
Step 303, based on that the maximum similarity among the similarities of the first combined reply statement and the K test statements is greater than a second threshold, taking the first combined reply statement as a candidate combined reply statement.
The second threshold may be determined according to actual needs, which is not specifically limited in this embodiment of the present application.
It is understood that the first combined reply statement and each of the K test statements correspond to a similarity, that is, K similarities in total, and if the maximum similarity among the K similarities is greater than the second threshold, the first combined reply statement is taken as a candidate combined reply statement.
Step 304, select one sentence from the candidate combined reply sentences and the N reply template sentences as the target reply sentence.
It is to be understood that the number of candidate compound reply sentences is less than or equal to Q, and may be specifically one or more.
It should be noted that there are various methods for selecting a reply statement from the candidate combined reply statements and the N reply template statements, and this is not specifically limited in the embodiment of the present application; for example, the selection may be random, or the candidate combination reply sentence may be preferentially selected. The method for selecting a target reply statement from the candidate combined reply statements and the N reply template statements will be described in detail with reference to fig. 7.
The above process is explained below as an example.
In this example, it is still assumed that the P combined statements include: "hello", "morning good" and "today's weather is also very good"; the Q combined reply sentences may include "also good weather today, good morning, and good you" in addition to "good morning, good you, and good weather today", "good morning, and good weather today" and "good you, good morning, and good weather today".
Based on the grammatical habits of the user, the user usually says 'hello' first, then says 'morning good' and 'weather is good today', and based on the situation, the 'weather is good today, morning good and you good' has grammatical problems.
Therefore, the similarity between the combined reply sentence "weather today is also good, morning is good, and you are good" calculated according to the pre-training model and each test sentence may be smaller than the second threshold, so that the combined reply sentence "weather today is also good, morning is good, and you are good" will not be used as a candidate combined reply sentence.
In the embodiment of the application, K test statements corresponding to a first combined reply statement are retrieved based on a retrieval model, then the similarity between the first combined reply statement and each test statement is calculated based on a pre-training model, and the first combined reply statement is used as a candidate combined reply statement based on the fact that the maximum similarity between the first combined reply statement and the K test statements is greater than a second threshold, so that the candidate combined reply statement is ensured to have no grammar and other related problems, namely, the availability of the candidate combined reply statement is ensured. Since the first combined reply statement is one of the Q combined reply statements, the same method can be used to process other combined reply statements in the Q combined reply statements to ensure the availability of the candidate combined reply statement.
As can be seen from the foregoing description, there are various methods for selecting a target reply statement from the candidate combined reply statements and the N reply template statements, and one of the methods is described below, namely, selecting a target reply statement from the candidate combined reply statements and the N reply template statements based on the probability distributions of the candidate combined reply statements and the N reply template statements.
Specifically, as shown in fig. 7, in another embodiment of determining a reply sentence provided by the present application, selecting one sentence from the candidate combined reply sentences and the N reply template sentences as the target reply sentence includes:
step 401, determining the probability of being selected corresponding to the candidate combined reply sentences and the N reply template sentences, wherein the probability of being selected corresponding to any one candidate combined reply sentence is greater than the probability of being selected corresponding to any one reply template sentence.
It should be noted that there are various methods for determining the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences, which are not specifically limited in this embodiment of the present application; for example, probabilities may be directly set for the candidate combined reply sentence and the N reply template sentences, respectively. In addition, another method for determining the probability is described below in conjunction with FIG. 8.
Step 402, selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence based on the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
It should be noted that, the method for selecting the reply statement according to the respective selected probabilities corresponding to the candidate combined reply statement and the N reply template statements is a relatively mature technology, and this is not specifically limited in the embodiment of the present application.
The above-described process is explained below as an example.
In this example, assume that the number of candidate combined reply sentences is two, N is 3; based on this, the probability that both of the two candidate combined reply sentences are selected may be directly set to 0.35, and the probability that all of the 3 candidate reply sentences are selected is set to 0.1, so that one sentence is finally selected from the two candidate combined reply sentences and the 3 candidate reply sentences as the reply sentence based on the set probabilities.
Compared with the candidate reply sentences, the candidate combined reply sentences have richer contents and can improve the intelligence of man-machine conversation, so that in the embodiment of the application, the probability of selecting any one of the candidate combined reply sentences is greater than the probability of selecting any one of the reply template sentences, and the probability of selecting the candidate combined reply sentences as the target reply sentences is greater than the probability of selecting the reply template sentences as the target reply sentences.
Another method for determining the probability of being selected for each of the candidate combined reply sentences and the N reply template sentences is described below with reference to fig. 8. In the method, the candidate combined reply sentences and the N reply template sentences are scored, and then the probability that the candidate combined reply sentences and the N reply template sentences are selected respectively is determined according to the scores.
Specifically, as shown in fig. 8, determining the probability that each of the candidate combined reply sentences and the N reply template sentences is selected includes:
step 501, determining the score of each candidate combined reply sentence according to the maximum similarity among the similarities of the candidate combined reply sentences and the corresponding K test sentences.
Based on the relevant descriptions in steps 301 to 303, each candidate combined reply statement corresponds to K test statements, a similarity between the candidate combined reply statement and each test statement corresponds to one, and the maximum similarity among the similarities between the candidate combined reply statement and the corresponding K test statements may be the maximum value of the similarities between the candidate combined reply statement and the corresponding K test statements.
There are various methods for determining the score of each candidate combined reply sentence according to the maximum similarity, and this is not particularly limited in the embodiment of the present application.
For example, the maximum similarity among the similarities of the candidate combined reply sentence and the corresponding K test sentences may be directly taken as the score of the candidate combined reply sentence.
In order to ensure that the probability of being selected corresponding to any one candidate combined reply sentence is greater than the probability of being selected corresponding to any one reply template sentence, firstly, the score corresponding to one candidate combined reply sentence is required to be greater than the score corresponding to any one reply template sentence; therefore, a preset similarity may be added on the basis of the maximum similarity among the similarities of the candidate combined reply sentence and the corresponding K test sentences, that is, the sum of the maximum similarity and the preset similarity among the similarities of the candidate combined reply sentence and the corresponding K test sentences is used as the score of the candidate combined reply sentence.
Step 502, a preset score is taken as the score of each candidate reply sentence in the N reply template sentences, and the preset score is smaller than the score of each candidate combined reply sentence.
It should be noted that the preset score may be set according to actual needs, and may be smaller than the score of each candidate combination reply statement.
For example, in step 501, if the maximum similarity among the similarities of the candidate combined reply sentences and the corresponding K test sentences is taken as the score of the candidate combined reply sentences, the preset score may be adjusted according to the score of each candidate combined reply sentence, so that the preset score is smaller than the score of each candidate combined reply sentence.
Specifically, assuming that the number of candidate combined reply sentences is three, and the maximum similarities among the similarities of the three candidate combined reply sentences and the corresponding K test sentences are 0.9, 0.95, and 0.98, respectively, 0.8 may be used as the preset score. Assuming that the number of candidate combined reply sentences is three, and the maximum similarities among the similarities of the three candidate combined reply sentences and the corresponding K test sentences are 0.94, 0.95 and 0.98, respectively, 0.9 may be used as the preset score.
In the above example, the preset score may be flexibly selected according to the score of each candidate combined reply sentence.
For another example, in step 501, if the sum of the maximum similarity and the preset similarity among the similarities of the candidate combined reply sentences and the corresponding K test sentences is used as the score of the candidate combined reply sentences, the preset similarity is set reasonably, so that the score of each candidate combined reply sentence is greater than 1, and at this time, the preset score may be set to be a fixed value of 1, without adjusting the preset score according to the score of each candidate combined reply sentence. Specifically, assuming that the preset similarity is 1, in a case where the maximum similarity among the similarities of the candidate combined reply sentence and the corresponding K test sentences takes any value between 0 and 1, the sum of the maximum similarity among the similarities of the candidate combined reply sentence and the corresponding K test sentences and the preset similarity is greater than 1, and thus the preset score value of 1 can be kept unchanged.
Step 503, normalizing the score of each candidate combined reply sentence and the score of each reply template sentence in the N reply template sentences to obtain the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
It is understood that, through the normalization process, the probabilities of being selected of the candidate combined reply sentence and the N reply template sentences are both greater than 0 and less than 1, and the sum of the probabilities of being selected of the candidate combined reply sentence and the N reply template sentences is 1.
Since the normalization process is a more sophisticated technique, it will not be described in detail here.
In the embodiment of the application, the candidate combined reply sentences and the N reply template sentences are scored, and then the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences are determined according to the scores, so that the probability of selecting the candidate combined reply sentences as the reply sentences is greater than the probability of selecting the reply template sentences as the reply sentences.
Referring to fig. 9, the present application provides an apparatus for determining a reply sentence, which may be applied to a server, including:
a first obtaining unit 601, configured to obtain M reply template statements corresponding to query statements in a human-computer conversation, where M is a positive integer;
a second obtaining unit 602, configured to obtain environment information from outside the human-computer conversation, where the environment information is related to the human-computer conversation;
a selecting unit 603, configured to select N reply template statements from M reply template statements according to the environment information, where N is a positive integer;
a determining unit 604, configured to determine the target reply statement according to the N reply template statements.
In some implementations, the M reply template statements include a first reply template statement, the first reply template statement being related to a first type of context information. A second obtaining unit 602, configured to obtain the first type of environment information from outside the human-computer conversation.
In some implementations, the first type of environmental information has a preset value; the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value; a selecting unit 603, configured to take the first reply template statement as one of the N reply template statements based on that the obtained first type of environment information is equal to a preset value.
In some implementations, the first type of environmental information has a preset value; the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value; the first reply template statement comprises a slot position, and the slot position is used for filling the first type of environment information.
The apparatus further includes a filling unit 605, configured to fill the obtained first type of environment information into the slot position based on that the obtained first type of environment information is equal to a preset value; the selecting unit 603 is further configured to fill the slot with the first reply template statement of the acquired first type of environment information as one of the N reply template statements.
In some implementation manners, the first reply template statement includes a slot position, and the slot position is used for filling first-class environmental information corresponding to the man-machine conversation; the apparatus further includes a filling unit 605, configured to fill the obtained first type of environment information into the slot; the selecting unit 603 is further configured to fill the slot with the first reply template statement of the acquired first type of environment information as one of the N reply template statements.
In some implementations, the determining unit 604 is configured to obtain P combined statements in N reply template statements, where N is greater than 1, and P is an integer greater than 1; obtaining Q combined reply sentences according to the P combined sentences, wherein each of the Q combined reply sentences is obtained by combining at least two combined sentences in the P combined sentences, and Q is a positive integer; and selecting one statement from the Q combined reply statements and the N reply template statements as a target reply statement.
In some implementations, the determining unit 604 is configured to retrieve K test statements corresponding to a first combined reply statement from a corpus according to a retrieval model, where the retrieval model is configured to output the test statement whose degree of correlation with the first combined reply statement is greater than a first threshold, and the first combined reply statement is any one of Q combined reply statements; calculating the similarity between the first combined reply statement and each test statement in the K test statements according to a pre-training model, wherein the pre-training model is used for calculating the similarity between the first combined reply statement and the test statements; taking the first combined reply sentence as a candidate combined reply sentence based on the fact that the maximum similarity in the similarities of the first combined reply sentence and the K test sentences is larger than a second threshold; and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence.
In some implementations, the determining unit 604 is configured to determine respective selected probabilities of the candidate combined reply sentences and the N reply template sentences, where the selected probability corresponding to any one of the candidate combined reply sentences is greater than the selected probability corresponding to any one of the reply template sentences; and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence based on the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
In some implementations, the determining unit 604 is configured to determine a score of each candidate combined reply sentence according to a maximum similarity among similarities of the candidate combined reply sentences and the corresponding K test sentences; taking a preset score as the score of each candidate reply sentence in the N candidate reply sentences, wherein the preset score is smaller than the score of each candidate combined reply sentence; and normalizing the score of each candidate combined reply sentence and the score of each reply template sentence in the N reply template sentences to obtain the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
Referring to fig. 10, an embodiment of a server in the embodiments of the present application may include one or more processors 701, a memory 702, and a communication interface 703.
The memory 702 may be transient storage or persistent storage. Still further, the processor 701 may be configured to communicate with the memory 702 to execute a series of instruction operations in the memory 702 on a server.
In this embodiment, the processor 701 may perform the operations performed by the server in the embodiment shown in fig. 9, which is not described herein again.
In this embodiment, the specific functional block division in the processor 701 may be similar to the functional block division described in fig. 9, and is not described herein again.
An embodiment of the present application further provides a chip or a chip system, where the chip or the chip system includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, and the at least one processor is configured to run a computer program or an instruction to execute operations performed by the server in the embodiment shown in fig. 9, which is not described herein again in detail.
The communication interface in the chip may be an input/output interface, a pin, a circuit, or the like.
The embodiments of the present application further provide a first implementation manner of a chip or a chip system, where the chip or the chip system described above in the present application further includes at least one memory, and the at least one memory stores instructions therein. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or may be a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
The embodiment of the present application further provides a computer storage medium, which is used for storing computer software instructions for the control device, and includes a program for executing the program designed for the server.
The server may determine the means for replying to the statement as described in the foregoing description of fig. 9.
An embodiment of the present application further provides a computer program product, where the computer program product includes computer software instructions, and the computer software instructions may be loaded by a processor to implement the flow in the method provided in any one of fig. 4 to 8.
Referring to fig. 11, an embodiment of the present application further provides a network system, which includes a terminal device 801 and a server 802.
The terminal device 801 is configured to send a query statement to the server, and the server 802 is configured to execute the method provided by any one of fig. 4 to 8.
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 several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is only one logical division, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.

Claims (13)

1. A method of determining a reply sentence, comprising:
acquiring M reply template sentences corresponding to query sentences in the man-machine conversation, wherein M is a positive integer;
acquiring environmental information from outside the man-machine conversation, wherein the environmental information is related to the man-machine conversation;
selecting N reply template sentences from the M reply template sentences according to the environment information, wherein N is a positive integer;
and determining the target reply statement according to the N reply template statements.
2. The method of claim 1, wherein the M reply template statements comprise a first reply template statement, the first reply template statement relating to a first type of context information;
the acquiring environmental information from outside the man-machine conversation comprises:
acquiring a first type of environment information from outside the man-machine conversation.
3. The method of claim 2, wherein the first type of environment information has a preset value;
the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value;
the selecting N reply template statements from the M reply template statements according to the environment information comprises:
and taking the first reply template statement as one of the N reply template statements based on the fact that the acquired first type of environment information is equal to a preset value.
4. The method of claim 2, wherein the first type of environment information has a preset value;
the first reply template statement is associated with a first applicable condition, and the first applicable condition indicates that the first reply template statement is applicable to the condition that the acquired first type of information is equal to a preset value;
the first reply template statement comprises a slot position, and the slot position is used for filling the first type of environment information;
the selecting N reply template statements from the M reply template statements according to the environment information comprises:
based on the fact that the obtained first-class environmental information is equal to a preset value, filling the obtained first-class environmental information into the slot position;
and taking the first reply template statement filled with the acquired first type of environment information in the slot position as one of the N reply template statements.
5. The method of claim 2, wherein the first reply template statement comprises a slot, and the slot is used for filling in the first type of environment information corresponding to the human-computer conversation;
the selecting N reply template statements from the M reply template statements according to the environment information comprises:
filling the obtained first type of environment information into the slot position;
and taking the first reply template statement filled with the acquired first type of environment information in the slot position as one of the N reply template statements.
6. The method of any of claims 1-5, wherein determining a target reply statement from the N reply template statements comprises:
acquiring P combined sentences in the N reply template sentences, wherein N is greater than 1, and P is an integer greater than 1;
obtaining Q combined reply statements according to the P combined statements, wherein each of the Q combined reply statements is obtained by combining at least two combined statements in the P combined statements, and Q is a positive integer;
and selecting one sentence from the Q combined reply sentences and the N reply template sentences as a target reply sentence.
7. The method of claim 6, wherein selecting one of the Q combined reply statements and the N reply template statements as a target reply statement comprises:
retrieving K test sentences corresponding to a first combined reply sentence from a corpus according to a retrieval model, wherein the retrieval model is used for outputting the test sentences the correlation degree of which with the first combined reply sentence is greater than a first threshold value, and the first combined reply sentence is any one of the Q combined reply sentences;
calculating the similarity between the first combined reply statement and each test statement in the K test statements according to a pre-training model, wherein the pre-training model is used for calculating the similarity between the first combined reply statement and the test statements;
taking the first combined reply statement as a candidate combined reply statement based on the fact that the maximum similarity in the similarities of the first combined reply statement and the K test statements is larger than a second threshold;
and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence.
8. The method of claim 7, wherein selecting one of the candidate combined reply sentences and the N reply template sentences as the target reply sentence comprises:
determining the probability of the candidate combined reply sentences and the probability of the N reply template sentences corresponding to being selected respectively, wherein the probability of the candidate combined reply sentences corresponding to being selected is greater than the probability of the reply template sentences corresponding to being selected;
and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence based on the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
9. The method of claim 8, wherein determining the probability that the candidate combined reply sentence and the N reply template sentences are selected in correspondence with each other comprises:
determining the score of each candidate combined reply sentence according to the maximum similarity in the similarities of the candidate combined reply sentences and the corresponding K test sentences;
taking a preset score as the score of each candidate reply sentence in the N candidate reply sentences, wherein the preset score is smaller than the score of each candidate combined reply sentence;
and normalizing the score of each candidate combined reply sentence and the score of each reply template sentence in the N reply template sentences to obtain the respective selected probabilities of the candidate combined reply sentences and the N reply template sentences.
10. An apparatus for determining a reply sentence, comprising:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring M reply template sentences corresponding to query sentences in the man-machine conversation, and M is a positive integer;
the second acquisition unit is used for acquiring environmental information from the outside of the man-machine conversation, and the environmental information is related to the man-machine conversation;
a selecting unit, configured to select N reply template statements from the M reply template statements according to the environment information, where N is a positive integer;
and the determining unit is used for determining the target reply statement according to the N reply template statements.
11. A server, comprising: at least one processor and a memory, the memory storing computer-executable instructions executable on the processor, the server performing the method of any one of claims 1-9 when the computer-executable instructions are executed by the processor.
12. A computer-readable storage medium storing one or more computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the processor performs the method of any one of claims 1-9.
13. A man-machine conversation system is characterized by comprising a terminal device and a server;
the terminal equipment is used for sending a query statement to the server;
the server is adapted to perform the method according to any of the claims 1-9 above.
CN202010630864.7A 2020-07-03 2020-07-03 Method and equipment for determining reply sentence and man-machine conversation system Pending CN111930884A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010630864.7A CN111930884A (en) 2020-07-03 2020-07-03 Method and equipment for determining reply sentence and man-machine conversation system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010630864.7A CN111930884A (en) 2020-07-03 2020-07-03 Method and equipment for determining reply sentence and man-machine conversation system

Publications (1)

Publication Number Publication Date
CN111930884A true CN111930884A (en) 2020-11-13

Family

ID=73317072

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010630864.7A Pending CN111930884A (en) 2020-07-03 2020-07-03 Method and equipment for determining reply sentence and man-machine conversation system

Country Status (1)

Country Link
CN (1) CN111930884A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023086207A1 (en) * 2021-11-15 2023-05-19 Microsoft Technology Licensing, Llc. Hybrid transformer-based dialog processor

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1637740A (en) * 2003-11-20 2005-07-13 阿鲁策株式会社 Conversation control apparatus, and conversation control method
CN108170749A (en) * 2017-12-21 2018-06-15 北京百度网讯科技有限公司 Dialogue method, device and computer-readable medium based on artificial intelligence
CN109101545A (en) * 2018-06-29 2018-12-28 北京百度网讯科技有限公司 Natural language processing method, apparatus, equipment and medium based on human-computer interaction
CN110442718A (en) * 2019-08-08 2019-11-12 腾讯科技(深圳)有限公司 Sentence processing method, device and server and storage medium
CN110472029A (en) * 2019-08-01 2019-11-19 腾讯科技(深圳)有限公司 A kind of data processing method, device and computer readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1637740A (en) * 2003-11-20 2005-07-13 阿鲁策株式会社 Conversation control apparatus, and conversation control method
CN108170749A (en) * 2017-12-21 2018-06-15 北京百度网讯科技有限公司 Dialogue method, device and computer-readable medium based on artificial intelligence
CN109101545A (en) * 2018-06-29 2018-12-28 北京百度网讯科技有限公司 Natural language processing method, apparatus, equipment and medium based on human-computer interaction
CN110472029A (en) * 2019-08-01 2019-11-19 腾讯科技(深圳)有限公司 A kind of data processing method, device and computer readable storage medium
CN110442718A (en) * 2019-08-08 2019-11-12 腾讯科技(深圳)有限公司 Sentence processing method, device and server and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2023086207A1 (en) * 2021-11-15 2023-05-19 Microsoft Technology Licensing, Llc. Hybrid transformer-based dialog processor

Similar Documents

Publication Publication Date Title
CN109086303B (en) Intelligent conversation method, device and terminal based on machine reading understanding
CN109635273B (en) Text keyword extraction method, device, equipment and storage medium
CN107797984B (en) Intelligent interaction method, equipment and storage medium
CN110245221B (en) Method and computer device for training dialogue state tracking classifier
CN110019732B (en) Intelligent question answering method and related device
TW202020691A (en) Feature word determination method and device and server
US11790174B2 (en) Entity recognition method and apparatus
CN112154465A (en) Method, device and equipment for learning intention recognition model
CN110309504B (en) Text processing method, device, equipment and storage medium based on word segmentation
CN114757176A (en) Method for obtaining target intention recognition model and intention recognition method
CN110909145A (en) Training method and device for multi-task model
CN109165286A (en) Automatic question-answering method, device and computer readable storage medium
US11379527B2 (en) Sibling search queries
CN111324705A (en) System and method for adaptively adjusting related search terms
CN111930884A (en) Method and equipment for determining reply sentence and man-machine conversation system
CN110347807B (en) Problem information processing method and device
CN109002498B (en) Man-machine conversation method, device, equipment and storage medium
US20230274161A1 (en) Entity linking method, electronic device, and storage medium
CN116975221A (en) Text reading and understanding method, device, equipment and storage medium
CN116401345A (en) Intelligent question-answering method, device, storage medium and equipment
CN110162615A (en) A kind of intelligent answer method, apparatus, electronic equipment and storage medium
CN116150376A (en) Sample data distribution optimization method, device and storage medium
CN116049370A (en) Information query method and training method and device of information generation model
CN109918661A (en) Synonym acquisition methods and device
CN111611369B (en) Interaction method and related device based on artificial intelligence

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