[go: up one dir, main page]

CN111930884B - A method, device and human-computer dialogue system for determining a reply sentence - Google Patents

A method, device and human-computer dialogue system for determining a reply sentence Download PDF

Info

Publication number
CN111930884B
CN111930884B CN202010630864.7A CN202010630864A CN111930884B CN 111930884 B CN111930884 B CN 111930884B CN 202010630864 A CN202010630864 A CN 202010630864A CN 111930884 B CN111930884 B CN 111930884B
Authority
CN
China
Prior art keywords
reply
sentences
sentence
combined
template
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.)
Active
Application number
CN202010630864.7A
Other languages
Chinese (zh)
Other versions
CN111930884A (en
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/CN111930884B/en
Publication of CN111930884A publication Critical patent/CN111930884A/en
Application granted granted Critical
Publication of CN111930884B publication Critical patent/CN111930884B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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 OR CALCULATING; 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 OR CALCULATING; 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Mathematical Physics (AREA)
  • Human Computer Interaction (AREA)
  • Machine Translation (AREA)

Abstract

The embodiment of the application discloses a method, equipment and a dialogue system for determining reply sentences. The method can be used for a server in a man-machine conversation system. After receiving an inquiry sentence, selecting N reply template sentences from the preconfigured diversified reply template sentences according to environment information outside the man-machine conversation, and finally determining a target reply sentence according to the N reply template sentences, so that the perception of the man-machine conversation system on the external environment information can be realized, and the diversification of the reply sentences is increased.

Description

Method and equipment for determining reply sentence and man-machine dialogue system
Technical Field
The present application relates to the field of artificial intelligence, and in particular, to a method, an apparatus, and a dialogue system for determining reply sentences.
Background
Artificial intelligence (ARTIFICIAL INTELLIGENCE, AI) is the theory, method, technique, and application system that simulates, extends, and extends human intelligence using a digital computer or a machine controlled by a digital computer, perceives the environment, obtains knowledge, and uses the knowledge to obtain optimal results. In other words, artificial intelligence is a branch of computer science that attempts to understand the essence of intelligence and to produce a new intelligent machine that can react in a similar manner to human intelligence. Artificial intelligence, i.e. research on design principles and implementation methods of various intelligent machines, enables the machines to have functions of sensing, reasoning and decision making
With the continuous development of artificial intelligence technology, natural language man-machine interaction systems that enable man-machine interaction through natural language are becoming more and more important. The man-machine interaction can be performed through natural language, and the system is required to recognize the specific meaning of the natural language of the human. Generally, the system recognizes a specific meaning of a sentence by employing key information extraction of the sentence in natural language.
At present, in the man-machine conversation process, after receiving an inquiry sentence of a user, the system selects a reply template sentence matched with the inquiry sentence from a reply template sentence set according to the inquiry sentence as a reply sentence, and then feeds back the reply sentence to the user.
Since the reply sentence is related to only the query sentence, the reply sentence is generally fixed for the same query sentence, and the diversity of the reply sentence is poor.
Disclosure of Invention
The embodiment of the application provides a method for determining reply sentences, and provides a device, a computer program product, a readable storage medium and a man-machine interaction system for realizing the method, which are used for increasing the diversity of the reply sentences.
In a first aspect, the present application provides a method for determining reply sentences, which can be applied to a server, and includes obtaining M reply template sentences corresponding to an inquiry sentence in a man-machine conversation, where M is a positive integer, and the reply template sentences may include text, numbers and slots. The environment information from outside the man-machine conversation is acquired, and 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 a target reply sentence according to the N reply template sentences. Further, one of the N reply template sentences may be used as the target reply sentence, or a plurality of the N reply template sentences may be combined into one target reply sentence.
Because the candidate N reply template sentences can be selected from the M reply template sentences according to the information outside the man-machine conversation, diversified reply template sentences can be input, and further 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 that is related to a first type of environmental information, where the first type of environmental information refers to one of the information from outside of the man-machine conversation.
Acquiring the environmental information from outside the man-machine conversation includes acquiring a first type of environmental information corresponding to the man-machine conversation from outside the man-machine conversation.
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 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 requirement of a user, and the first applicable condition can be in various forms.
Selecting N reply template sentences from the M reply template sentences according to the environment information comprises:
And taking the first reply template statement as one of N reply template statements based on the acquired first type of environment information being equal to a 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 N 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, 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 first reply template statement comprises a slot position used for filling the first type of environment information.
Selecting N reply template sentences from the M reply template sentences according to the environment information comprises filling the acquired first-type environment information into the slot based on the acquired first-type environment information being equal to a preset value, and taking the first reply template sentence filled with the acquired first-type environment information in the slot as one of the N reply template sentences.
In some implementations, the first reply template statement includes a slot, the slot is used for filling first type environment information corresponding to the man-machine conversation, and selecting N reply template statements from the M reply template statements according to the environment information includes filling the acquired first type environment information into the slot, and the first reply template statement with the acquired first type environment information filled in the slot is used as one of the N reply template statements.
In this implementation manner, it is not necessary to determine whether the first type of environment information corresponding to the man-machine conversation is a preset value, and after the first type of environment information corresponding to the man-machine conversation is obtained, the first reply template sentence can be directly used as one of the N reply template sentences.
In some implementations, determining the target reply sentence according to the N reply template sentences includes obtaining P combination sentences in the N reply template sentences, wherein N is greater than 1, P is an integer greater than 1, obtaining Q combination reply sentences according to the P combination sentences, wherein each of the Q combination reply sentences is obtained by combining at least two combination sentences in the P combination sentences, Q is a positive integer, and selecting one sentence from the Q combination reply sentences and the N reply template sentences as the target reply sentence.
And combining the P combined sentences to obtain Q combined reply sentences, and selecting one sentence from the Q combined reply sentences and 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, thereby increasing the diversity of the reply sentences.
In some implementations, selecting one sentence from the Q combined reply sentences and the N reply template sentences as the target reply sentence includes retrieving K test sentences corresponding to the first combined reply sentence from the corpus according to the retrieval model. The corpus typically contains a variety of corpora, where corpora refers to what is also known as free text, which may be words, sentences, fragments, articles, and any combination thereof. The search model may be a search model based on TF-IDF (term frequency-inverse document frequency) technology, and is configured to output test sentences having a degree of relevance to a first combined reply sentence that is any one of Q combined reply sentences, the degree of relevance to the first combined reply sentence being greater than a first threshold.
And calculating the similarity between the first combined reply sentence and each test sentence in the K test sentences according to a pre-training model, wherein the pre-training model is used for calculating the similarity between the first combined reply sentence and the test sentences, and the similarity can be expressed by the distance between vectors. And selecting one sentence from the candidate combined reply sentences and N reply template sentences as a target reply sentence based on the maximum similarity in the similarity between the first combined reply sentence and the K test sentences is larger than a second threshold value.
In the implementation manner, based on the fact that the maximum similarity of the first combined reply sentence and the K test sentences is larger than the second threshold, the first combined reply sentence is used as a candidate combined reply sentence, so that the fact that the candidate combined reply sentence has no grammar and other related problems is guaranteed, namely the usability of the candidate combined reply sentence is guaranteed.
In some implementations, selecting one sentence from the candidate combined reply sentence and the N reply template sentences as the target reply sentence includes determining a selected probability corresponding to each of the candidate combined reply sentence and the N reply template sentences, wherein 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 sentence and the N reply template sentences as the target reply sentence based on the selected probabilities corresponding to each of the candidate combined reply sentence and the N reply template sentences.
Compared with reply template sentences, the content of the candidate combined reply sentences is richer, and the intelligence of man-machine conversation can be improved, so that in the embodiment of the application, the probability of being selected corresponding to any one candidate combined reply sentence is larger than the probability of being selected corresponding to any one reply template sentence, and the probability of selecting the candidate combined reply sentence as a target reply sentence is larger than the probability of selecting the reply template sentence as a reply sentence.
In some implementations, determining the selected probabilities of the candidate combined reply sentence and the N reply template sentences respectively comprises determining a score of each candidate combined reply sentence according to the maximum similarity of the candidate combined reply sentence and the 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 selected probabilities of the candidate combined reply sentence and the N reply template sentences respectively.
In the implementation manner, the candidate combined reply sentence and the N reply template sentences are scored, and then the selected probabilities corresponding to the candidate combined reply sentence and the N reply template sentences are determined according to the scores, so that the probability of selecting the candidate combined reply sentence as the reply sentence is greater than that of selecting the candidate combined reply sentence as the reply sentence.
In a second aspect, the present application provides an apparatus for determining a reply sentence, including:
the first acquisition unit is used for acquiring M reply template sentences corresponding to the inquiry sentences in the man-machine conversation, wherein M is a positive integer;
The second acquisition unit is used for acquiring environment information from outside the man-machine conversation, wherein the environment 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 sentence according to the N reply template sentences.
In some implementations, the M reply template statements include a first reply template statement, the first reply template statement being related to the first type of environmental 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 environment information has a preset value, the first reply template statement is associated with a first applicable condition, the first applicable condition indicates that the first reply template statement is applicable to a situation that the acquired first type of information is equal to the preset value, and the selection unit is used for taking the first reply template statement as one of N reply template statements based on the acquired first type of environment information is equal to the preset value.
In some implementations, the first type of environment information has a preset value, the first reply template statement is associated with a first applicable condition, the first applicable condition indicates that the first reply template statement is applicable to the situation that the acquired first type of information is equal to the preset value, and the first reply template statement comprises a slot for filling the first type of environment information.
The device further comprises a filling unit used for filling the acquired first-type environment information into the slot based on the acquired first-type environment information being equal to a preset value, and a selecting unit used for filling the first reply template statement filled with the acquired first-type environment information into the slot as one of N reply template statements.
In some implementations, the first reply template statement includes a slot for filling first type of environment information corresponding to the man-machine conversation, the device further includes a filling unit for filling the acquired first type of environment information into the slot, and the selecting unit is further used for filling the first reply template statement with the acquired first type of environment information in the slot as one of the N reply template statements.
In some implementations, the determining unit is configured to obtain P combined sentences in the N reply template sentences, where N is greater than 1 and P is an integer greater than 1, obtain Q combined reply sentences according to the P combined sentences, where each of the Q combined reply sentences is obtained by combining at least two combined sentences in the P combined sentences, and select one sentence from the Q combined reply sentences and the N reply template sentences as a target reply sentence.
In some implementations, the determining unit is configured to retrieve K test sentences corresponding to the first combined reply sentence from the corpus according to a retrieval model, the retrieval model is configured to output test sentences having a correlation degree with the first combined reply sentence greater than a first threshold, the first combined reply sentence is any one of the Q combined reply sentences, calculate a similarity between the first combined reply sentence and each of the K test sentences according to a pre-training model, the pre-training model is configured to calculate a similarity between the first combined reply sentence and the test sentences, and select the first combined reply sentence as a candidate combined reply sentence based on the maximum similarity between the first combined reply sentence and the K test sentences being greater than a second threshold, and select one sentence from the candidate combined reply sentence and the N reply template sentences as a target reply sentence.
In some implementations, the determining unit is configured to determine the selected probabilities corresponding to the candidate combined reply sentence 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 select one sentence from the candidate combined reply sentence and the N reply template sentences as the target reply sentence based on the selected probabilities corresponding to the candidate combined reply sentence 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 in the similarity between the candidate combined reply sentence and the corresponding K test sentences, use the preset score as a score of each candidate reply sentence in the N candidate reply sentences, use the preset score as a score of each candidate combined reply sentence, use the preset score as a score smaller than the score of each candidate combined reply sentence, and normalize 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 selected probabilities corresponding to the candidate combined reply sentence and the N reply template sentences.
In a third aspect, the application provides a server comprising at least one processor and a memory storing computer-executable instructions executable on the processor, the server performing the method provided in any one of the first aspects when the computer-executable instructions are executed by the processor.
In a fourth aspect, the present application provides a 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 wire, the at least one processor being adapted to execute a computer program or instructions to perform a method as provided in any one of the first aspects above.
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 in any one of the first aspects.
In a sixth aspect, the present application provides a computer program product for storing a computer program which, when executed by one or more processors, implements the method provided in any one of the first aspects.
In a seventh aspect, the present application provides a human-machine conversation system, including a terminal device and a server.
The terminal device is configured to send an inquiry sentence to a server, and the server is configured to execute the method provided in any one of the first aspects.
From the above technical solutions, the embodiment of the present application has the following advantages:
The system acquires environment information from outside the man-machine conversation, the environment information is related to the man-machine conversation, N reply template sentences are selected from the M reply template sentences according to the environment information, N is a positive integer, the perception of the system to the external environment information is realized, and because the N reply template sentences can be selected according to the environment information from outside the man-machine conversation, the diversified reply template sentences can be preconfigured, the M reply template sentences corresponding to the query sentences can be diversified, then different reply template sentences can be selected based on different information from outside the man-machine conversation, the finally determined target reply sentences are not fixed, the diversity of the target reply sentences is good, and the user experience in the man-machine conversation process can be improved.
Drawings
FIG. 1 is a schematic diagram of a man-machine interaction system according to an embodiment of the present application;
FIG. 2 is an interface diagram of a new construction intent according to an embodiment of the present application;
FIG. 3 is an interface diagram of a slot configuration in an embodiment of the present application;
FIG. 4 is a diagram illustrating a first embodiment of determining a reply sentence according to an embodiment of the present application;
FIG. 5 is a diagram illustrating a second embodiment of determining a reply sentence according to an embodiment of the present application;
FIG. 6 is a diagram illustrating a first embodiment of selecting a reply sentence according to an embodiment of the present application;
FIG. 7 is a diagram illustrating a second embodiment of selecting a reply sentence according to an embodiment of the present application;
FIG. 8 is a diagram of an embodiment of determining a probability that a sentence is selected in an embodiment of the present application;
FIG. 9 is a schematic diagram of an apparatus for determining reply sentences according to an embodiment of the present application;
FIG. 10 is a schematic diagram of a server according to 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 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 that the experience of a user in the man-machine conversation process is improved.
The following description of the technical solutions according to the embodiments of the present invention will be given with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The method of the embodiment of the application can be applied to the man-machine interaction system shown in fig. 1. The man-machine interaction system comprises user equipment, data input equipment and data processing equipment.
The user equipment comprises intelligent terminals such as a user, a mobile phone, a personal computer or an information processing center. The user equipment is an initiating terminal of human-machine dialogue, and is used as an initiating party of a request such as a language question answer or a query, and the user initiates the request through the user equipment. The user equipment in fig. 1 includes a mobile phone, a tablet computer and a notebook computer.
The data input device may be a terminal device such as a computer, and is configured to input 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 web server, an application server, and a management server. The data processing equipment receives inquiry sentences such as inquiry sentences/voices/texts from the intelligent terminal through the interactive interface, and then carries out 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 comprising a database of locally stored as well as stored history data, which may be on the data processing device or on other network servers.
Taking the man-machine interaction system shown in fig. 1 as an example, in order to increase diversity of reply sentences, in the embodiment of the application, the data input device is used for inputting the diversified reply template sentences into a database corresponding to the data processing device, so that the data processing device can screen reply template sentences matched with the inquiry sentences from the database after receiving the inquiry request from the intelligent terminal, then further screen the reply template sentences according to information outside the man-machine conversation, and determine target reply sentences according to the screened reply template sentences. Because the input reply template sentences are diversified and different candidate reply sentences can be selected based on different information from outside the man-machine conversation, the finally determined target reply sentences are not fixed, the diversity of the target reply sentences is good, and the user experience in the man-machine conversation process is improved.
The following describes the method according to the embodiment of the present application in detail for the sake of understanding.
It can be appreciated that the method of the embodiment of the application comprises two processes of reply template statement entry and determination of reply statements. The procedure of replying to the template statement entry is first described below.
Reply template statement input process
The recording personnel operate on the data recording equipment, and record the diversified reply template sentences into the data processing equipment.
There are various ways to enter the reply template statement. As one way of realisation, a diversity of reply template statements may be sorted into the data processing device.
In particular, the typing person may build a plurality of intent templates on the data typing device, each intent template comprising a corresponding set of query templates and a set of reply templates, each set of query templates comprising one or more query template statements, each set of reply templates comprising 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 to reply.
In an embodiment of the application, each intent template represents a class of reply template statements. The name of the intention template may be set as desired, for example, travel, weather, place, study, and any other name. As shown in fig. 2, the intention template includes a set of query templates including three query template sentences of "hello", "hi" and "hello", and a set of reply templates including four reply template sentences of "hello", "good" and "weather today is also good".
The reply template sentence may include a word, a number, and a slot, as shown in fig. 2, and the reply template sentence "_good" in the reply template sentence "_good" indicates the slot, where the slot is used for filling information. For example, after filling "morning" in the slot, the reply template statement becomes "good morning".
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 relevant configuration may include a variety of.
For example, the relevant configuration of the reply template statement may include a combined reply message that includes an indication of whether or not to combine in the intent template and a combination order, as shown in FIG. 2. The method comprises the steps of determining whether a plurality of reply template sentences in an intention template are combined into one reply sentence or not, wherein the indication of whether the reply template sentences in the intention template are combined or not represents whether the reply template sentences in the intention template can be combined into one reply sentence or not, and the combination order refers to the maximum number of the reply template sentences which can be combined in the same intention template. Taking fig. 2 as an example, the combination order is 3, which means that one reply template sentence can be used as a reply sentence, 2 reply template sentences can be combined to be used as a target reply sentence, or 3 reply template sentences can be combined to be used as a target reply sentence, and if the combination order is 2, which 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 cannot be combined to be used as target reply sentences.
For example, the relevant configuration of the reply template statement may include a pre-trained model for verifying whether the combined statement is available. In fig. 2, the pre-training models include a first pre-training model, a second pre-training model, and a third pre-training model.
For example, the relevant configuration of the reply template sentence may further include an applicable condition of the reply template sentence, where the applicable condition is represented in a plurality of ways, and the embodiment of the present application is not limited in particular. As shown in FIG. 2, the application condition corresponding to the reply template sentence "hello" is automatic analysis, the automatic analysis can be understood as being applicable under any condition, when the application condition is automatic analysis, the user is not required to enter specific application conditions, so that the input process can be simplified, the input efficiency is improved, and similarly, the application condition corresponding to one reply template sentence "_good" is also automatic analysis, and represents "_good" is applicable under any condition. The applicable condition corresponding to the other reply template statement "_good" is that the day length type is afternoon, namely "_good" is applicable under the condition that the day length type is afternoon. The corresponding applicable condition of the reply template sentence "weather is good today" is weather fine ", namely the reply template sentence" weather is good today "is applicable under weather fine conditions.
It will be appreciated that since the reply template statement contains slots, the relevant configuration of the reply template statement may also include parameters for the slots. Specifically, the parameters of the slot may include the type of slot and the name of the slot.
The slot types may include a conditional slot for filling information acquired from context information in a man-machine conversation and a normal slot for filling environment information acquired from outside the man-machine conversation, as shown in fig. 3. The condition slots may in turn comprise a system internal condition slot for filling in environmental information outside the man-machine conversation obtained from the inside of the data processing device, which may for example comprise a system time and a system date, and an external resource condition slot for filling in information outside the man-machine conversation obtained from a resource external to the data processing device, which may for example comprise a location where the man-machine conversation occurs, weather at the location where the man-machine conversation occurs, humidity at the location where the man-machine conversation occurs, and temperature at the location where the man-machine conversation occurs.
The names of the slots can be set according to actual needs, and in the embodiment of the application, the slot names can be set as the information types filled in the slots, for example, the slot names can be traffic mode types and weather types. When the slot position name is of a traffic mode type, the slot position can be filled with a specific traffic mode, and when the slot position name is of a weather type, the slot position can 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 weather type.
The procedure of entering the reply template sentence is described above, and the procedure of determining the reply sentence based on the above-described entry of the reply template sentence is described below.
Procedure for determining reply statements
Referring to fig. 4, a first embodiment of determining a reply sentence according to an embodiment of the present application is shown. As shown in fig. 4, an embodiment of the present application provides a method for determining a reply sentence, which may be applied to the data processing apparatus shown in fig. 1, and includes:
Step 101, obtaining M reply template sentences corresponding to the query sentences in the man-machine conversation, wherein M is a positive integer.
In the man-machine conversation process, the data processing device receives the query statement from the intelligent terminal, the form of the query statement is not limited in particular, for example, the query statement can be composed of one word or one word, and the query statement can comprise one statement or a plurality of statements.
Upon receiving the query statement, the data processing device retrieves a reply template statement from the database for replying to the query statement.
It should be noted that, there are various methods for obtaining M reply template sentences corresponding to the query sentence, and the embodiment of the present application is not limited in this way.
For example, based on the inclusion of multiple intent templates in the database, each intent template contains a set of query templates and a set of reply templates. The data processing device may calculate the similarity between the query sentence and the query template sentence in each of the intent templates, and if the similarity between the query sentence and one of the intent templates is greater than a preset first similarity, may list all the reply template sentences in the intent template into M reply template sentences corresponding to the query sentence.
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 the man-machine conversation, wherein the environment information is related to the man-machine conversation.
The information in the man-machine conversation can be understood as context information in the man-machine conversation, and the environment information outside the man-machine conversation refers to information in the non-man-machine conversation.
For example, the environmental information from outside the human-machine conversation may include environmental information from outside the human-machine conversation acquired from inside the data processing apparatus, such as may include a system time (i.e., time at which the human-machine conversation occurs) and a system date (i.e., date at which the human-machine conversation occurs), and the environmental information from outside the human-machine conversation acquired from a resource external to the data processing apparatus may include, for example, a location at which the human-machine conversation occurs, weather at the location at which the human-machine conversation occurs, humidity at the location at which the human-machine conversation occurs, and temperature at the location at which the human-machine conversation occurs.
It should be noted that, based on the environmental information related to the man-machine conversation, the environmental information may reflect an actual scene of the man-machine conversation, for example, the environmental information may be a location where the man-machine conversation occurs, weather at the location where the man-machine conversation occurs, and the like. The environment information is related to man-machine interaction, and the embodiment of the application is not limited in particular.
The method for acquiring the environmental information from outside the man-machine conversation may be varied, and the present application is not particularly limited thereto, and a method for acquiring the environmental information from outside the man-machine conversation will be described in detail hereinafter.
And step 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 context information is related to the man-machine conversation, the context information may be used as a filtering condition of the reply template sentence, for example, if some reply template sentences may contradict the context information, the reply template sentence cannot be used as one of the N reply template sentences.
For example, assuming that the environmental information from outside the human-machine conversation includes "weather today is rain", the reply template sentence "weather today is also good" cannot be one of N reply template sentences, and still assuming that the environmental information from outside the human-machine conversation includes "weather today is rain", the reply template sentence "basketball on the playground" cannot be one of N reply template sentences.
Therefore, N reply template sentences may be selected from the M reply template sentences based on the environment information, and the method for selecting N reply template sentences may be various, which is not particularly limited in the embodiment of the present application, and hereinafter, a method for selecting N reply template sentences will be specifically described.
Step 104, determining the target reply sentence according to the N reply template sentences.
The method for determining the target reply sentence according to the N reply template sentences is various, for example, one of the N reply template sentences may be directly used as the target reply sentence, a plurality of the N reply template sentences may be combined to obtain the target reply sentence, and one of the N reply template sentences or the sentence obtained by combining may be further optimized to obtain the target reply sentence.
The method for determining reply sentences from the N reply template sentences will be specifically described hereinafter with reference to the drawings.
In the embodiment of the present application, taking the intent template shown in fig. 2 as an example, one query template sentence is "hello", and since M reply template sentences can be selected according to the environmental information from outside the man-machine conversation, the reply template sentences can correspondingly include "hello" and also "today's weather is good". When the environmental information from outside the man-machine conversation is "weather today is rain," then "hello" may be selected as one of the N reply template sentences, and "weather today is also good" may not be selected as one of the N reply template sentences. When the environmental information from outside the man-machine conversation is weather including today, then weather today is also good as one of the N reply template sentences.
If the actual weather of the place where the man-machine conversation occurs is rain, the weather of today cannot be used as one of the N reply template sentences, so that the selected candidate reply sentence is not applicable to the actual scene of the man-machine conversation, the weather of today cannot be used as the reply template sentence, and only the sentence applicable to the scene of any man-machine conversation can be used as the reply template sentence, thereby limiting the diversification of the input reply template sentence and leading the finally determined target reply sentence to lack of diversification.
Therefore, in the embodiment of the application, the data processing equipment can sense the change of the environment information outside the man-machine conversation, then select N reply template sentences from M reply template sentences according to the environment information outside the man-machine conversation, and because N reply template sentences can be selected from the M reply template sentences according to the environment information outside the man-machine conversation, diversified reply template sentences can be input in the input process of the reply template sentences, so that the selected candidate reply sentences are diversified, and the finally determined reply sentences can be diversified and unfixed, thereby improving the user experience.
Based on the above description, the content of the environment information from outside the man-machine conversation may be various, and as one possibility, the environment information from outside the man-machine conversation is related to the reply template sentence.
Specifically, in another embodiment of the method for determining reply sentences provided by the embodiment of the present application, the M reply template sentences include first reply template sentences, and the first reply template sentences are related to the first type of environment information corresponding to the man-machine conversation.
The first type of environmental information refers to one of environmental information from outside of the man-machine conversation.
Based on the correlation of 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 acquiring the first type of environment information from outside the man-machine conversation.
The above is further described below with an example.
Based on the weather, the data processing device can acquire the weather of the position where the man-machine conversation occurs, and the actual value can be sunny, rainy or cloudy.
Based on the time, the data processing device can acquire the time of the human-machine conversation, and the actual value can be morning, afternoon or evening.
In the embodiment of the present application, there are various ways to indicate that the first reply template sentence is related to the first type of environmental information corresponding to the man-machine conversation, which is not specifically limited in the embodiment of the present application.
Two ways of representing that the first reply template sentence is related to the first type of environment information corresponding to the man-machine conversation are described below.
Based on the foregoing, as an achievable way, the first type of environment information has a preset value, the first reply template sentence is associated with the first applicable condition, and the first applicable condition indicates that the first reply template sentence is applicable to the acquired condition that the first type of information is equal to the preset value.
The preset value may be set according to actual needs of the user, for example, the preset value may be fine if the weather of the place where the human-machine conversation occurs is assumed to be the first type of environmental information, and the preset value may be morning if the time when the human-machine conversation occurs is assumed to be the first type of environmental information.
The first applicable condition may be various, for example, as shown in fig. 2, the first applicable condition "weather fine" may be used to indicate that weather of the location where the man-machine conversation occurs is fine, or the first applicable condition "day long type is afternoon" may be used to indicate that the day long type corresponding to the time when the man-machine conversation occurs is afternoon.
Based on the first applicable condition, selecting N reply template sentences from the M reply template sentences according to the environment information includes:
And taking the first reply template statement as one of N reply template statements based on the acquired first type of environment information being equal to a preset value.
In the embodiment of the application, a first applicable condition is adopted to express that a first reply template statement is related to first type of environment information corresponding to the man-machine conversation, and based on 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 N reply template statements.
Based on the foregoing description, the input reply template sentence may include a slot, and in the input process of the reply template sentence, parameters of the slot are also input, for example, a name of the slot may be used to represent a type of information filled in the slot.
Therefore, in another embodiment of determining the reply sentence provided by the embodiment of the present application, the first reply template sentence includes a slot, where the slot is used to fill the first type of environmental information corresponding to the man-machine interaction.
It should be noted that the parameters of the slot may be used to represent the slot for filling the first type of environment information corresponding to the man-machine conversation, and the names of the slot may be used to represent the slot for filling the first type of environment information corresponding to the man-machine conversation. For example, a slot name "traffic pattern type" may be used to indicate that the slot is used to fill traffic patterns that exist at the location where the human-machine conversation occurs, and a slot name "weather pattern" may be used to indicate that the slot is used to fill weather at the location where the human-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 sentences from the M reply template sentences according to the environment information comprises:
Filling the acquired first-class environmental information into the slot position based on the acquired first-class environmental information being equal to a preset value;
and filling the first reply template statement with the acquired first type of environment information in the slot as one of N reply template statements.
As shown in fig. 2, it is assumed that the first reply template sentence is "_good" in fig. 2, the first applicable condition is "day length type is afternoon" in fig. 2, and it is indicated that the first reply template sentence "_good" is applicable when the day length type to which the time of occurrence of the human-machine conversation belongs is afternoon, that is, the first type of environment information is the day length type to which the time of occurrence of the human-machine conversation belongs, and the reply template sentence contains a slot, and it is assumed that the slot is used for filling the day length type to which the time of occurrence of the human-machine conversation corresponds.
If the day length type of the time of the man-machine conversation is afternoon, the afternoon can be filled into the slot, and then the first reply template sentence is changed into afternoon.
In the embodiment of the application, besides the first application condition that the first reply template statement is related to the first type of environment information corresponding to the man-machine conversation, the slot position is used for indicating that the first reply template statement is related to the first type of environment information corresponding to the man-machine conversation.
In another embodiment of determining the reply sentence provided by the embodiment of the present application, the slot may be used only to represent that the first reply template sentence is related to the first type of environmental information corresponding to the man-machine interaction.
Specifically, the first reply template statement includes a slot, and the slot is used for filling first type environment information corresponding to man-machine conversation.
Since the foregoing embodiments have been described with respect to the slot, the slot in the embodiments of the present application can be understood with reference to the description of the slot in the foregoing embodiments.
Selecting N reply template sentences from the M reply template sentences according to the environment information comprises:
filling the acquired first type of environment information into the slot;
and filling the first reply template statement with the acquired first type of environment information in the slot as one of N reply template statements.
It can be understood that, unlike the foregoing embodiment, the embodiment of the present application does not need to determine whether the first type of environment information corresponding to the man-machine conversation is a preset value, and after the first type of environment information corresponding to the man-machine conversation is obtained, the first reply template sentence can be directly used as one of the N reply template sentences.
As shown in fig. 2, assuming that the first reply template sentence is "_good" in fig. 2, the corresponding applicable condition is automatic analysis, and since automatic analysis can be understood to be applicable under any condition, it can be considered that the applicable condition is not adopted to indicate that the first reply template sentence "_good" is related to the first type of environment information corresponding to the man-machine conversation, and only the slot in the first reply template sentence "_good" indicates that the first reply template sentence "_good" is related to the first type of environment information corresponding to the man-machine conversation.
It can be understood that if the slot in the first reply template sentence is used for filling the daily length type of the time when the man-machine conversation occurs, that is, the daily length type of the first environmental information is the daily length type of the time when the man-machine conversation occurs, and the daily length type of the time when the man-machine conversation occurs is the morning, the morning can be filled into the slot, and the first reply template sentence becomes "good morning".
In the foregoing embodiment, the data processing apparatus selects N reply template sentences from the M reply template sentences by sensing the environmental information from outside the man-machine conversation, so that diversification of the N reply template sentences can be increased, and further diversification of the determined target reply sentences can be increased.
In addition, a plurality of reply template sentences can be combined to be used as reply sentences, so that the diversity of the reply sentences is increased.
Specifically, based on the foregoing embodiments, in another embodiment of determining a reply sentence provided by the embodiment of the present application, as shown in fig. 5, determining a target reply sentence according to N candidate reply sentences may include:
Step 201, obtaining P combined sentences in the N reply template sentences, where N is greater than 1 and P is an integer greater than 1.
It should be noted that, the combined sentence may be determined according to the aforementioned combined reply information, for example, P reply template sentences in the N reply template sentences are associated with the combined reply information, where the combined reply information indicates that at least two reply template sentences in the P reply template sentences may be combined into one combined reply sentence, and then the P reply template sentences may be used as P combined sentences.
It should be noted that the form of the combined reply message may be various, and the embodiment of the application is not limited in particular, and based on the process of inputting the reply template statement, the combined reply message may include an indication of whether to combine in each intention template and a combination order.
And, the indication of whether to combine and the combination order are corresponding to the intention templates, that is, the indication of whether to combine is used for indicating whether the reply template sentences in the corresponding intention templates can be combined, the combination order is the maximum number of the reply template sentences which can be combined in the corresponding intention templates.
Therefore, in the embodiment of the application, the combined reply information can indicate that multiple groups of reply template sentences in the P reply template sentences can be respectively combined, specifically, each group of reply template sentences comprises multiple reply template sentences, and part or all of reply template sentences in each group of reply template sentences can be combined into one combined reply sentence.
Based on the process of inputting the reply template sentences, at least two combined sentences belonging to the same intention template in the P combined sentences can be combined to obtain the combined reply sentences, so that the combined sentences corresponding to the two combined reply sentences can belong to the same intention template or different graph templates.
Each combined reply sentence can be obtained by combining two combined sentences, can be obtained by combining three combined sentences, or can be obtained by combining three or more combined sentences, and the embodiment of the application is not particularly limited to this.
For example, suppose P combined sentences include "hello", "good in the morning" and "good in the weather today", Q combined reply sentences may include "hello, good in the morning", "good in the weather today", "good in the morning", good in the weather today "and" good in the weather today, good in the weather today ".
Step 202, 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.
In step 203, one sentence is selected from the Q combined reply sentences and the N reply template sentences as the target reply sentence.
It can be understood that, in order to increase the diversity of reply sentences, reply sentences are selected from Q combined reply sentences and N reply template sentences, i.e. reply sentences may be combined reply sentences or non-combined reply sentences.
It should be noted that, there are various methods for selecting the target reply sentence from the Q combined reply sentences and the N reply template sentences, and the embodiment of the present application is not limited to this, and for example, the method may be a random selection or a preferential selection of the combined reply sentence. A method of selecting a target reply sentence from the Q combined reply sentences and the N reply template sentences will be described in detail hereinafter with reference to fig. 6. In the embodiment of the application, candidate reply sentences in the P combined sentences are combined to obtain Q combined reply sentences, and then one sentence is selected from the Q combined reply sentences and the N reply template sentences as a target reply sentence, so that the reply sentence can be one of the Q combined reply sentences or one of the N reply template sentences, thereby increasing the diversity of the reply sentences.
Based on the above description, there are various methods for selecting reply sentences from the Q combined reply sentences and the N reply template sentences, one of which is described below.
Because the combined reply sentence is obtained by automatically combining a plurality of candidate reply sentences by the data processing equipment, the combined reply sentence may have grammar problems, namely, the combined reply sentence does not accord with grammar habits of users, and other problems may also exist in the combined reply sentence.
Specifically, as shown in fig. 6, in another embodiment of the determination reply sentence provided by the present application, selecting one sentence from Q combined reply sentences and N reply template sentences as a target reply sentence includes:
step 301, retrieving K test sentences corresponding to the first combined reply sentence from the corpus according to a retrieval model, where the retrieval model is used to output test sentences with a correlation degree with the first combined reply sentence greater than a first threshold, and the first combined reply sentence is any one of the Q combined reply sentences.
The corpus typically contains a plurality of corpora, wherein the corpora refers to what is also called free text, which may be words, sentences, fragments, articles, and any combination thereof, and wherein each test sentence is a corpus of the corpus.
It should be noted that, the search model may be understood as a model for constructing a search similar sentence based on the sentences of the first combined reply sentence, where the search model may be various, and the embodiment of the present application is not limited to this, and for example, the search model may be a search model based on TF-IDF (Term Frequency-inverse document Frequency) technology, where TF is a Term Frequency (Term Frequency), and IDF is an inverse text Frequency index (Inverse Document Frequency).
The first threshold may be set according to actual needs, which is not specifically limited in the embodiment of the present application.
In the embodiment of the application, the test statement is used as a comparison statement of the combined reply statement and is used for testing whether the combined reply statement has grammar and other problems.
For example, assuming that the first combined reply sentence is "hello, weather today is also good", the K test sentences may include "hello, weather today is good", "hello, weather today is good" and "hello, weather today is true good".
Step 302, calculating the similarity between the first combined reply sentence and each test sentence in the K test sentences according to a pre-training model, where the pre-training model is used to calculate the similarity between the first combined reply sentence and the test sentence.
The pre-training model may include a plurality of computing models, for example, may be based on a neural network, specifically, the first combined reply sentence and the test sentence may be represented as vectors, and then, by calculating a distance between the vectors, a similarity between the first combined reply sentence and each test sentence may be calculated.
The embodiments of the present application are not specifically limited herein, based on the pre-training model being a more sophisticated technique.
Step 303, based on the maximum similarity of the similarities between the first combined reply sentence and the K test sentences being greater than the second threshold, the first combined reply sentence is used as a candidate combined reply sentence.
The second threshold may be determined according to actual needs, which is not specifically limited in the embodiment of the present application.
It can be understood that the first combined reply sentence corresponds to one similarity between the first combined reply sentence and each of the K test sentences, that is, K total similarities, and if the maximum similarity in the K similarities is greater than the second threshold, the first combined reply sentence is used as a candidate combined reply sentence.
Step 304, selecting one sentence from the candidate combined reply sentences and N reply template sentences as a target reply sentence.
It can be appreciated that the number of candidate combined reply sentences is less than or equal to Q, and may specifically be one or more.
It should be noted that, there are various methods for selecting reply sentences from the candidate combined reply sentences and the N reply template sentences, and the embodiment of the present application is not limited to this, and for example, the reply sentences may be selected randomly or may be selected preferentially. A method of selecting a target reply sentence from among the candidate combined reply sentence and the N reply template sentences will be described in detail hereinafter with reference to fig. 7.
The above-described process is described below with an example.
In this example, it is still assumed that P combined sentences include "hello", "good morning" and "good weather today". Q combined reply sentences may include "good weather today", "good weather morning", "good weather today" and "good weather morning, good weather today", and "good weather today", as well as "good weather today, good weather morning, good weather, good weather morning".
Based on the grammar habit of the user, the user usually speaks "hello" first, then speaks "good morning" and "good weather today", and based on this, "good weather today and good weather early, the hello" has grammar problems.
Therefore, the similarity between the combined reply sentence of "today weather is good, and is good early, and the combined reply sentence of" hello "and each test sentence is possibly smaller than the second threshold value, so that the combined reply sentence of" today weather is good, and is good early, and the combined reply sentence of "hello" is not used as a candidate combined reply sentence.
In the embodiment of the application, K test sentences corresponding to the first combined reply sentence are searched based on a search model, then the similarity between the first combined reply sentence and each test sentence is calculated based on a pre-training model, and the first combined reply sentence is used as a candidate combined reply sentence based on the fact that the maximum similarity of the similarity between the first combined reply sentence and the K test sentences is larger than a second threshold, so that the situation that grammar and other related problems do not exist in the candidate combined reply sentence is ensured, namely the usability of the candidate combined reply sentence is ensured. Because the first combined reply sentence is one of the Q combined reply sentences, other combined reply sentences in the Q combined reply sentences can be processed by adopting the same method so as to ensure the availability of candidate combined reply sentences.
Based on the foregoing, there are various methods for selecting the target reply sentence from the candidate combined reply sentence and the N reply template sentences, and one of the methods is described below, namely, selecting the target reply sentence from the candidate combined reply sentence and the N reply template sentences based on probability distributions of the candidate combined reply sentence and the N reply template sentences.
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 sentence and the N reply template sentences as a target reply sentence includes:
step 401, determining the selected probabilities corresponding to the candidate combined reply sentence and the N reply template sentences, where the selected probability corresponding to any one candidate combined reply sentence is greater than the selected probability corresponding to any one reply template sentence.
It should be noted that, there are various methods for determining the probabilities of the candidate combined reply sentence and the N reply template sentences that are selected and correspond to each other, and the embodiment of the present application is not limited to this, and for example, the probabilities may be set for the candidate combined reply sentence and the N reply template sentences directly. In addition, another method of determining probability will be described below in conjunction with fig. 8.
Step 402, selecting one sentence from the candidate combined reply sentence and the N reply template sentences as a target reply sentence based on the probabilities of the candidate combined reply sentence and the N reply template sentences, which correspond to the selected probabilities.
It should be noted that, the method of selecting the reply sentence according to the probability of being selected corresponding to each of the candidate combined reply sentence and the N reply template sentences is a mature technology, which is not limited in detail in the embodiment of the present application.
The above-described process is described below with an example.
In this example, assuming that the number of candidate combined reply sentences is two and N is 3, based on this, the probability that two candidate combined reply sentences are selected may be set to 0.35, and the probability that 3 candidate reply sentences are selected is set to 0.1, one sentence is finally selected from the two candidate combined reply sentences and the 3 candidate reply sentences as a reply sentence based on the set probability.
Compared with the candidate reply sentences, the content of the candidate combined reply sentences is richer, and the intelligence of man-machine conversation can be improved, so that in the embodiment of the application, the probability of being selected corresponding to any one candidate combined reply sentence is larger than the probability of being selected corresponding to any one reply template sentence, and the probability of selecting the candidate combined reply sentence as a target reply sentence is larger than the probability of selecting the reply template sentence as the target reply sentence.
Another method of determining the probabilities of the candidate combined reply sentence and the N reply template sentences being selected, respectively, is described below in conjunction with fig. 8. In the method, candidate combined reply sentences and N reply template sentences are scored, and then the selected probabilities corresponding to the candidate combined reply sentences and the N reply template sentences are determined according to the scores.
Specifically, as shown in fig. 8, determining the probabilities of the candidate combined reply sentence and the N reply template sentences that correspond to each includes:
Step 501, determining the score of each candidate combined reply sentence according to the maximum similarity in the similarity between the candidate combined reply sentence and the corresponding K test sentences.
Based on the relevant descriptions in steps 301 to 303, each candidate combined reply sentence corresponds to K test sentences, one similarity corresponds to each candidate combined reply sentence, and the maximum similarity in the similarities between the candidate combined reply sentence and the corresponding K test sentences may be the maximum value of the similarities between the candidate combined reply sentence and the corresponding K test sentences.
There are various methods for determining the score of each candidate combined reply sentence according to the maximum similarity, and embodiments of the present application are not limited thereto in detail.
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 selected probability corresponding to any one candidate combined reply sentence is larger than the selected probability corresponding to any one reply template sentence, the score corresponding to one candidate combined reply sentence is required to be ensured to be larger than the score corresponding to any one reply template sentence, so that the sum of the maximum similarity and the preset similarity in the similarity of the candidate combined reply sentence and the corresponding K test sentences can be used as the score of the candidate combined reply sentence on the basis of the maximum similarity in the similarity of the candidate combined reply sentence and the corresponding K test sentences.
And step 502, taking the preset score as the score of each candidate reply sentence in the N reply template sentences, wherein the preset score is smaller than the score of each candidate combined reply sentence.
It should be noted that, the size of the preset score may be set according to actual needs, so long as the preset score is smaller than the score of each candidate combined reply sentence.
For example, in step 501, if the maximum similarity between the candidate combined reply sentence and the corresponding K test sentences is used as the score of the candidate combined reply sentence, the preset score may be adjusted according to the score of each candidate combined reply sentence, such 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, the maximum similarity among the similarities of the three candidate combined reply sentences and the corresponding K test sentences is 0.9, 0.95 and 0.98, respectively, 0.8 may be taken as the preset score. Assuming that the number of candidate combined reply sentences is three, the maximum similarity among the similarities of the three candidate combined reply sentences and the corresponding K test sentences is 0.94, 0.95 and 0.98, respectively, then 0.9 can be used as a 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 in the similarity between the candidate combined reply sentence and the corresponding K test sentences is used as the score of the candidate combined reply sentence, the preset similarity is reasonably set, 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 the 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, so that the preset score can be kept unchanged as 1.
And 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 selected probabilities corresponding to the candidate combined reply sentences and the N reply template sentences.
It can be understood that, through the normalization process, the probabilities of the candidates for the combined reply sentence and the N reply template sentences being selected respectively are all greater than 0 and less than 1, and the sum of the probabilities of the candidates for the combined reply sentence and the N reply template sentences being selected respectively is 1.
Since normalization is a relatively mature technique, it is not described in detail herein.
In the embodiment of the application, the candidate combined reply sentence and N reply template sentences are scored, and then the probabilities of the candidate combined reply sentence and N reply template sentences, which correspond to each other, are determined according to the scores, so that the probability of selecting the candidate combined reply sentence as the reply sentence is greater than that of selecting the candidate combined reply sentence as the reply sentence.
Referring to fig. 9, the present application provides a device for determining reply sentences, which can be applied to a server, and includes:
a first obtaining unit 601, configured to obtain M reply template sentences corresponding to the query sentences in the man-machine conversation, where M is a positive integer;
A second obtaining unit 602, configured to obtain environmental information from outside the man-machine conversation, where the environmental information is related to the man-machine conversation;
A selecting unit 603, configured to select N reply template sentences from the M reply template sentences according to the environmental information, where N is a positive integer;
A determining unit 604, configured to determine a target reply sentence according to the N reply template sentences.
In some implementations, the M reply template statements include a first reply template statement, the first reply template statement being related to the first type of environmental information. A second obtaining unit 602, configured to obtain the first type of environmental information from outside the man-machine conversation.
In some implementations, the first type of environment information has a preset value, the first reply template statement is associated with a first applicable condition, the first applicable condition indicates that the first reply template statement is applicable to a situation that the acquired first type of information is equal to the preset value, and the selecting unit 603 is configured to use the first reply template statement as one of the N reply template statements based on the acquired first type of environment information is equal to the preset value.
In some implementations, the first type of environment information has a preset value, the first reply template statement is associated with a first applicable condition, the first applicable condition indicates that the first reply template statement is applicable to the situation that the acquired first type of information is equal to the preset value, and the first reply template statement comprises a slot for filling the first type of environment information.
The apparatus further comprises a filling unit 605 for filling the acquired first type of environment information into the slot based on the acquired first type of environment information being equal to a preset value, and a selecting unit 603 for filling the slot with the first reply template sentence of the acquired first type of environment information as one of the N reply template sentences.
In some implementations, the first reply template sentence includes a slot for filling the first type of environment information corresponding to the man-machine conversation, the apparatus further includes a filling unit 605 for filling the acquired first type of environment information into the slot, and the selecting unit 603 is further configured to fill the first reply template sentence with the acquired first type of environment information in the slot as one of the N reply template sentences.
In some implementations, the determining unit 604 is configured to obtain P combined sentences in the N reply template sentences, where N is greater than 1 and P is an integer greater than 1, obtain Q combined reply sentences according to the P combined sentences, where Q is a positive integer, and select one sentence from the Q combined reply sentences and the N reply template sentences as a target reply sentence.
In some implementations, the determining unit 604 is configured to retrieve K test sentences corresponding to the first combined reply sentence from the corpus according to a retrieval model, the retrieval model is configured to output test sentences having a correlation degree with the first combined reply sentence greater than a first threshold, the first combined reply sentence is any one of the Q combined reply sentences, calculate a similarity between the first combined reply sentence and each of the K test sentences according to a pre-training model, the pre-training model is configured to calculate a similarity between the first combined reply sentence and the test sentences, and select the first combined reply sentence as a candidate combined reply sentence based on the maximum similarity between the first combined reply sentence and the K test sentences being greater than a second threshold, and select one sentence from the candidate combined reply sentence and the N reply template sentences as a target reply sentence.
In some implementations, the determining unit 604 is configured to determine the selected probabilities corresponding to the candidate combined reply sentence 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 select one sentence from the candidate combined reply sentence and the N reply template sentences as the target reply sentence based on the selected probabilities corresponding to the candidate combined reply sentence 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 in the similarity between the candidate combined reply sentence and the corresponding K test sentences, use the preset score as a score of each candidate reply sentence in the N candidate reply sentences, use the preset score as a score smaller than the score of each candidate combined reply sentence, and normalize 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 selected probabilities corresponding to the candidate combined reply sentence and the N reply template sentences.
Referring to fig. 10, one embodiment of a server in an embodiment of the application may include one or more processors 701, memory 702, and a communication interface 703.
The memory 702 may be a transient or persistent store. Still further, the processor 701 may be configured to communicate with the memory 702 and 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 are not described herein.
In this embodiment, the specific functional module division in the processor 701 may be similar to the functional module division described in fig. 9, and will not be repeated here.
The 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, where the communication interface and the at least one processor are interconnected by a line, and the at least one processor is configured to execute a computer program or instructions to perform an operation performed by the server in the embodiment shown in fig. 9, which is not described herein in detail.
The communication interface in the chip can be an input/output interface, a pin, a circuit or the like.
The embodiment of the application also provides a first implementation manner of the chip or the chip system, and the chip or the chip system further comprises at least one memory, wherein the at least one memory stores instructions. The memory may be a memory unit within the chip, such as a register, a cache, etc., or may be a memory unit of the chip (e.g., a read-only memory, a random access memory, etc.).
The embodiment of the application also provides a computer storage medium for storing computer software instructions for the control device, which includes a program for executing the program designed for the server.
The server may determine means for replying to the statement as described in the foregoing fig. 9.
Embodiments of the present application also provide a computer program product comprising computer software instructions loadable by a processor to implement the flow of the method provided in any of the above figures 4 to 8.
Referring to fig. 11, the 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 an inquiry sentence to a server, and the server 802 is configured to execute the method provided in any one of fig. 4 to 8 described above.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described systems, apparatuses and units may refer to corresponding procedures in the foregoing method embodiments, which are not repeated herein.
In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown 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 may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in part or all of the technical solution or in part in the form of a software product stored in a storage medium, including instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. The storage medium includes a U disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, an optical disk, or other various media capable of storing program codes.

Claims (8)

1.A method of determining a reply sentence, comprising:
M reply template sentences corresponding to the inquiry sentences in the man-machine conversation are obtained, wherein M is a positive integer;
acquiring environment information from outside the man-machine conversation, wherein the environment 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;
Determining a target reply sentence according to the N reply template sentences;
The M reply template sentences comprise first reply template sentences, the environment information comprises first type environment information, the first reply template sentences are related to the first type environment information, the first type environment information has a preset value, the first reply template sentences are related to first applicable conditions, the first applicable conditions indicate that the first reply template sentences are applicable to the condition that the acquired first type environment information is equal to the preset value, the first reply template sentences comprise slots, and the slots are used for filling the first type environment information;
The selecting N reply template sentences from the M reply template sentences according to the environment information comprises:
filling the acquired first-class environmental information into the slot position based on the acquired first-class environmental information being equal to a preset value;
Filling the first reply template statement with the acquired first type of environment information in the slot as one of the N reply template statements;
the determining the target reply sentence according to the N reply template sentences comprises:
P combined sentences in the N reply template sentences are obtained, wherein N is greater than 1, and P is an integer greater than 1;
Q combined reply sentences are obtained according to the P combined sentences, 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 sentence from the Q combined reply sentences and the N reply template sentences as a target reply sentence.
2. The method of claim 1, wherein the selecting one statement from 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 with the correlation degree of the first combined reply sentence being 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 sentence and each test sentence in the K test sentences according to a pre-training model, wherein the pre-training model is used for calculating the similarity between the first combined reply sentence and the test sentences;
Based on the maximum similarity in the similarity between the first combined reply sentence and the K test sentences is larger than a second threshold value, taking the first combined reply sentence as a candidate combined reply sentence;
and selecting one sentence from the candidate combined reply sentences and the N reply template sentences as a target reply sentence.
3. The method of claim 2, wherein selecting one sentence from the candidate combined reply sentence and the N reply template sentences as a target reply sentence comprises:
Determining the selected probabilities corresponding to the candidate combined reply sentences and the N reply template sentences, wherein the selected probability corresponding to any one candidate combined reply sentence is larger than the selected probability corresponding to any one reply template sentence;
And selecting one sentence from the candidate combined reply sentence and the N reply template sentences as a target reply sentence based on the candidate combined reply sentence and the selected probabilities corresponding to the N reply template sentences.
4. The method of claim 3, wherein determining the selected probabilities for each of the candidate combined reply sentence and the N reply template sentences comprises:
determining the score of each candidate combined reply sentence according to the maximum similarity in the similarity between the candidate combined reply sentence and the corresponding K test sentences;
taking the preset score as the score of each candidate reply sentence in the N reply template 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 selected probabilities corresponding to the candidate combined reply sentences and the N reply template sentences.
5. An apparatus for determining reply sentences, comprising:
the first acquisition unit is used for acquiring M reply template sentences corresponding to the inquiry sentences in the man-machine conversation, wherein M is a positive integer;
The second acquisition unit is used for acquiring environment information from outside the man-machine conversation, and the environment 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;
The determining unit is used for determining a target reply sentence according to the N reply template sentences;
The M reply template sentences comprise first reply template sentences, the first reply template sentences are related to first type of environment information, the first type of environment information has preset values, the first reply template sentences are related to first applicable conditions, the first applicable conditions indicate the condition that the first reply template sentences are applicable to the acquired first type of information equal to the preset values, the first reply template sentences comprise slots, and the slots are used for filling the first type of environment information;
The selection unit is used for:
filling the acquired first-class environmental information into the slot position based on the acquired first-class environmental information being equal to a preset value;
Filling the first reply template statement with the acquired first type of environment information in the slot as one of the N reply template statements;
The determining unit is used for:
P combined sentences in the N reply template sentences are obtained, wherein N is greater than 1, and P is an integer greater than 1;
Q combined reply sentences are obtained according to the P combined sentences, 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 sentence from the Q combined reply sentences and the N reply template sentences as a target reply sentence.
6. A server comprising at least one processor and a memory storing computer-executable instructions executable on the processor, the server performing the method of any one of claims 1-4 when the computer-executable instructions are executed by the processor.
7. A computer readable storage medium storing one or more computer-executable instructions, wherein the computer-executable instructions, when executed by a processor, perform the method of any of the preceding claims 1-4.
8. The man-machine conversation system is characterized by comprising terminal equipment and a server;
the terminal equipment is used for sending an inquiry statement to the server;
the server being adapted to perform the method of any of the preceding claims 1-4.
CN202010630864.7A 2020-07-03 2020-07-03 A method, device and human-computer dialogue system for determining a reply sentence Active CN111930884B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010630864.7A CN111930884B (en) 2020-07-03 2020-07-03 A method, device and human-computer dialogue system for determining a reply sentence

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010630864.7A CN111930884B (en) 2020-07-03 2020-07-03 A method, device and human-computer dialogue system for determining a reply sentence

Publications (2)

Publication Number Publication Date
CN111930884A CN111930884A (en) 2020-11-13
CN111930884B true CN111930884B (en) 2025-01-14

Family

ID=73317072

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010630864.7A Active CN111930884B (en) 2020-07-03 2020-07-03 A method, device and human-computer dialogue system for determining a reply sentence

Country Status (1)

Country Link
CN (1) CN111930884B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114093360A (en) * 2021-10-18 2022-02-25 北京声智科技有限公司 Calling method, calling device, electronic equipment and storage medium
US12032627B2 (en) 2021-11-15 2024-07-09 Microsoft Technology Licensing, Llc Hybrid transformer-based dialog processor
CN116361424A (en) * 2021-12-27 2023-06-30 中国移动通信有限公司研究院 Dialog reply method, device, communication device and readable storage medium
CN114328870A (en) * 2021-12-27 2022-04-12 深圳乐信软件技术有限公司 Reply message generation method, system and device

Citations (2)

* 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

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109101545A (en) * 2018-06-29 2018-12-28 北京百度网讯科技有限公司 Natural language processing method, apparatus, equipment and medium based on human-computer interaction
CN109241250A (en) * 2018-07-25 2019-01-18 南京瓦尔基里网络科技有限公司 A kind of dialogue of policing rule promotes and intention method of discrimination and system
CN110472029B (en) * 2019-08-01 2024-03-19 腾讯科技(深圳)有限公司 Data processing method, device and computer readable storage medium
CN110442718B (en) * 2019-08-08 2023-12-08 腾讯科技(深圳)有限公司 Statement processing method and device, server and storage medium
CN110909142B (en) * 2019-11-20 2023-03-31 腾讯科技(深圳)有限公司 Question and sentence processing method and device of question-answer model, electronic equipment and storage medium
CN111026842B (en) * 2019-11-29 2023-09-12 微民保险代理有限公司 Natural language processing method, natural language processing device and intelligent question-answering system

Patent Citations (2)

* 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

Also Published As

Publication number Publication date
CN111930884A (en) 2020-11-13

Similar Documents

Publication Publication Date Title
US11334635B2 (en) Domain specific natural language understanding of customer intent in self-help
CN111930884B (en) A method, device and human-computer dialogue system for determining a reply sentence
CN110097085B (en) Lyric text generation method, training method, device, server and storage medium
CN108287858B (en) Semantic extraction method and device for natural language
CN111274365B (en) Intelligent inquiry method and device based on semantic understanding, storage medium and server
JP6529761B2 (en) Topic providing system and conversation control terminal device
CN114757176A (en) Method for obtaining target intention recognition model and intention recognition method
CN101183351B (en) Literal input method and system thereof
US11379527B2 (en) Sibling search queries
CN111026320B (en) Multi-mode intelligent text processing method and device, electronic equipment and storage medium
CN113505293A (en) Information pushing method and device, electronic equipment and storage medium
CN118797060A (en) A method, system, device and medium for constructing a search enhancement generation system
CN113505889B (en) Processing method and device of mapping knowledge base, computer equipment and storage medium
CN117933260A (en) Text quality analysis method, device, equipment and storage medium
RU2759090C1 (en) Method for controlling a dialogue and natural language recognition system in a platform of virtual assistants
CN118760759A (en) Document-oriented question-answering method, device, electronic device, storage medium and product
CN113590797A (en) Intelligent operation and maintenance customer service system and implementation method
CN110347807B (en) Problem information processing method and device
CN118093660A (en) Library data processing method and device, electronic equipment and storage medium
CN116975083A (en) Information searching method, information searching device, computer equipment and storage medium
CN116975221A (en) Text reading and understanding method, device, equipment and storage medium
CN118113864A (en) Text emotion classification method and device, electronic equipment and storage medium
CN114218364A (en) Question-answer knowledge base expansion method and device
CN114548083B (en) Title generation method, device, equipment and medium
RU2818036C1 (en) Method and system for controlling dialogue agent in user interaction channel

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
GR01 Patent grant
GR01 Patent grant