A multi-role dialogue method, device and electronic equipment

By encoding statements in judicial trials into syntactic trees and generating encoding vectors, the problem of lack of specificity and temporality of statements in multi-role debates in traditional judicial trials is solved, and efficient multi-role dialogue processing is achieved.

CN114186033BActive Publication Date: 2025-12-12ALIBABA GROUP HOLDING LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010960471.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-14
Publication Date
2025-12-12
Estimated Expiration
2040-09-14

AI Technical Summary

Technical Problem

Traditional dialogue systems in judicial trials cannot effectively handle multi-role arguments, resulting in a lack of focus and sequence in statements, and low efficiency.

Method used

By encoding multiple target statements into a syntax tree and generating encoding vectors based on roles and syntax trees, the decoding process distinguishes different roles for asking or answering questions. Instead of simply concatenating all statements, the syntax tree structure is used to distinguish roles.

Benefits of technology

It enables targeted questioning and answering for different roles in judicial trials and other scenarios, thereby improving trial efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114186033B_ABST
    Figure CN114186033B_ABST
Patent Text Reader

Abstract

The present disclosure provides a multi-role dialogue method, device and electronic equipment, the method comprising: obtaining a plurality of target sentences; wherein the plurality of target sentences correspond to at least one role; encoding each target sentence into a corresponding syntax tree; encoding the role and syntax tree corresponding to each target sentence to obtain an encoding vector; decoding the syntax tree and the encoding vector to obtain a reply sentence of the plurality of target sentences.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of Internet, and more particularly, to a multi-role dialogue method, a multi-role dialogue device, an electronic device, and a computer readable storage medium. BACKGROUND

[0002] With the development of social economy and the improvement of cultural and educational level, people's legal consciousness is also getting stronger and stronger. The number of cases in court trials is increasing. The traditional judicial trial is conducted by the judge asking the plaintiff and the defendant, and the plaintiff and the defendant answer the relevant questions, and finally the court makes the final decision according to the information of the plaintiff and the defendant. This way of judging cases needs more time, consumes more manpower and material resources, and is low in efficiency.

[0003] Therefore, artificial intelligence based on information technology has been embedded in the judicial field and has built into a modern sense of wisdom trial activity, which has great significance. With the advancement of wisdom trial, the efficiency of judicial trial has been greatly improved.

[0004] The traditional dialogue system is realized based on a sequence-to-sequence model, but for the scene of judicial trial, it involves multi-role trial debate, such as judge, plaintiff, defendant, plaintiff's agent, defendant's agent, plaintiff's lawyer and defendant's lawyer. Because of the existence of multiple roles, any person in the multi-person dialogue may be questioned or stated, so each sentence in the debate does not have a specific purpose. Moreover, the sequence-to-sequence model is limited to the time sequence relationship between sentences, but for the dialogue, the words spoken by different people may not have a time sequence. SUMMARY

[0005] An object of the present disclosure is to provide a new technical solution for multi-role dialogue.

[0006] According to a first aspect of the present disclosure, a multi-role dialogue method is provided, comprising:

[0007] obtaining a plurality of target sentences; wherein the plurality of target sentences correspond to at least one role;

[0008] encoding each target sentence into a corresponding syntax tree;

[0009] encoding according to the role and the syntax tree corresponding to each target sentence to obtain an encoding vector;

[0010] decoding according to the syntax tree and the encoding vector to obtain a reply sentence of the plurality of target sentences.

[0011] Optionally, the encoding according to the role and the syntax tree corresponding to each target sentence to obtain an encoding vector comprises:

[0012] determining a role corresponding to each syntax tree;

[0013] splicing syntax trees corresponding to the same role to obtain a parent syntax tree of the same role;

[0014] fusing a preset role word vector corresponding to the same role and each syntax tree in the parent syntax tree to obtain a fused parent syntax tree of the same role;

[0015] encoding the fused parent syntax tree of each role respectively to obtain the encoding vector.

[0016] Optionally, the decoding according to the syntax tree and the encoding vector to obtain the reply statement of the target statement includes:

[0017] determining a correlation score between any two words in the syntax tree corresponding to the target statement;

[0018] generating a correlation score matrix according to the correlation score;

[0019] decoding according to the correlation score matrix and the encoding vector to obtain the reply statement of the target statement.

[0020] Optionally, the determining the correlation score between any two words in the syntax tree corresponding to the target statement includes:

[0021] determining the distance of the any two words in the syntax tree corresponding to the target statement in the syntax tree as the correlation score of the any two words.

[0022] Optionally, the decoding according to the correlation score matrix and the encoding vector to obtain the reply statement of the target statement includes:

[0023] linearly transforming the correlation score matrix of the target statement to obtain a score tensor;

[0024] weighting and transforming the encoding vector through an attention mechanism to obtain an output tensor;

[0025] splicing the score tensor and the output tensor to obtain a spliced tensor;

[0026] decoding the spliced tensor to obtain the reply statement.

[0027] Optionally, the role corresponding to the target statement is determined by the following method, including:

[0028] obtaining a role keyword in the target statement; wherein the role keyword is a preset keyword reflecting the name of the corresponding role;

[0029] determining a role corresponding to the target sentence according to the role keyword.

[0030] Optionally, the method further comprises:

[0031] In a case where the target sentence includes a specified keyword, the step of encoding each target sentence according to a role corresponding to the target sentence and a parent syntax tree to obtain an encoding vector of each role is performed.

[0032] Optionally, the method further comprises:

[0033] playing the reply sentence; and / or,

[0034] displaying the reply sentence.

[0035] According to a second aspect of the present disclosure, a multi-role dialogue device is provided, comprising:

[0036] a sentence obtaining module configured to obtain a plurality of target sentences; wherein the plurality of target sentences correspond to at least one role;

[0037] a syntax tree generating module configured to encode each target sentence into a corresponding syntax tree;

[0038] an encoding module configured to encode each target sentence according to a role corresponding to the target sentence and the syntax tree to obtain an encoding vector;

[0039] a decoding module configured to decode the syntax tree and the encoding vector to obtain a reply sentence of the plurality of target sentences.

[0040] According to a third aspect of the present disclosure, an electronic device is provided, comprising:

[0041] a processor and a memory, the memory being configured to store instructions for controlling the processor to perform the method according to the first aspect of the present disclosure.

[0042] According to a fourth aspect of the present disclosure, a computer readable storage medium is provided, which stores a computer program, the computer program being configured to implement the method according to the first aspect of the present disclosure when executed by a processor.

[0043] In embodiments of the present disclosure, at least one role input target sentence is encoded into a corresponding syntax tree, and encoding is performed according to the role and the syntax tree to obtain an encoding vector, and decoding is performed according to the syntax tree and the encoding vector to obtain a reply sentence. By adopting a syntax tree structure, the syntax tree of each role is distinguished, rather than simply concatenating all sentences. In this way, different roles can be distinguished, and questions or answers can be asked or given for different roles.

[0044] Other features and advantages of the present disclosure will be apparent from the following detailed description of example embodiments thereof, taken in conjunction with the accompanying drawings of which: BRIEF DESCRIPTION OF DRAWINGS

[0045] The accompanying drawings incorporated in and forming a part of the specification illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0046] Figure 1a is a schematic diagram of a hardware structure of an electronic device according to a first embodiment of the present disclosure.

[0047] Figure 1b is a schematic diagram of a hardware structure of an electronic device according to a second embodiment of the present disclosure.

[0048] Figure 2 is a schematic diagram of an application scenario of a multi-role dialogue method according to an embodiment of the present disclosure.

[0049] Figure 3 is a flowchart of a multi-role dialogue method according to an embodiment of the present disclosure.

[0050] Figure 4 is a schematic diagram of an example of a syntax tree according to an embodiment of the present disclosure.

[0051] Figure 5 is a schematic diagram of a principle block diagram of a multi-role dialogue device according to an embodiment of the present disclosure.

[0052] Figure 6 is a schematic diagram of a principle block diagram of an electronic device according to a third embodiment of the present disclosure. DETAILED DESCRIPTION

[0053] Various example embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. If it is considered that the relative arrangement, numerical expressions, and numerical values of components and steps set forth in these embodiments limit the scope of the present disclosure, unless otherwise specifically stated, the scope of the present disclosure is not limited thereto.

[0054] The following description of at least one example embodiment is merely exemplary in nature and is in no way intended to limit the present disclosure or its application or uses.

[0055] Techniques, methods, and devices known to those of ordinary skill in the relevant art can not be discussed in detail herein, but should be considered as part of the description if appropriate.

[0056] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary, and not as a limitation. Thus, other examples of example embodiments can have different values.

[0057] It should be noted that like numerals refer to like items throughout the drawings and that once an item is defined in one drawing, it is not necessary to discuss it further in subsequent drawings.

[0058] <Hardware Configuration>

[0059] Figure 1a and Figure 1b is a block diagram of a hardware configuration of an electronic device 1000 that can be used to implement a method of any embodiment of the present disclosure.

[0060] In one embodiment, as shown in Figure 1a , the electronic device 1000 can be a server 1100.

[0061] The server 1100 is a computer that provides processing, database, communications facilities, etc. The server 1100 can be a monolithic server or a distributed server across multiple computers or computer data centers. The server can be various types, such as, but not limited to, a web server, a news server, a mail server, a messaging server, an advertisement server, a file server, an application server, an interaction server, a database server, or a proxy server. In some embodiments, each server can include hardware, software, or embedded logic components or a combination of two or more such components for performing suitable functions supported or implemented by the server. For example, the server, such as a blade server, a cloud server, etc., or a group of servers composed of multiple servers, can include one or more of the above-mentioned types of servers, etc.

[0062] In this embodiment, the server 1100 can include a processor 1110, a memory 1120, an interface device 1130, a communication device 1140, a display device 1150, and an input device 1160, as shown in Figure 1a .

[0063] In this embodiment, the server 1100 can further include a speaker, a microphone, etc., which are not limited herein.

[0064] The processor 1110 can be a dedicated server processor, or a desktop processor, a mobile processor, etc. that meets performance requirements, which are not limited herein. The memory 1120 includes, for example, a ROM (Read Only Memory), a RAM (Random Access Memory), a non-volatile memory such as a hard disk, etc. The interface device 1130 includes, for example, various bus interfaces, such as a serial bus interface (including a USB interface), a parallel bus interface, etc. The communication device 1140 is capable of wired or wireless communication, for example. The display device 1150 is, for example, a liquid crystal display screen, an LED display screen, a touch display screen, etc. The input device 1160 can include, for example, a touch screen, a keyboard, etc.

[0065] In this embodiment, the memory 1120 of the server 1100 is configured to store instructions for controlling the processor 1110 to operate to perform at least the method according to any embodiment of the present disclosure. The skilled person can design the instructions according to the disclosed solutions of the present disclosure. How the instructions control the processor to operate is known in the art and will not be described in detail here.

[0066] Although a plurality of devices of the server 1100 are shown in Figure 1a , the present disclosure can only involve part of the devices, for example, the server 1100 only involves the memory 1120 and the processor 1110.

[0067] In one embodiment, the electronic device 1000 can be a terminal device 1200 used by an operator, such as a PC, a notebook computer, etc., which is not limited here.

[0068] In this embodiment, referring to Figure 1b , the terminal device 1200 can include a processor 1210, a memory 1220, an interface device 1230, a communication device 1240, a display device 1250, an input device 1260, a loudspeaker 1270, a microphone 1280, etc.

[0069] The processor 1210 can be a mobile version processor. The memory 1220 includes, for example, a ROM (Read Only Memory), a RAM (Random Access Memory), a non-volatile memory such as a hard disk, etc. The interface device 1230 includes, for example, a USB interface, a headset interface, etc. The communication device 1240 can perform wired or wireless communication, for example. The communication device 1240 can include a short-distance communication device, for example, any device that performs short-distance wireless communication based on a Hilink protocol, a WiFi (IEEE 802.11 protocol), a Mesh, a Bluetooth, a ZigBee, a Thread, a Z-Wave, an NFC, a UWB, a LiFi, etc. The communication device 1240 can also include a long-distance communication device, for example, any device that performs WLAN, GPRS, 2G / 3G / 4G / 5G long-distance communication. The display device 1250 is, for example, a liquid crystal display screen, a touch display screen, etc. The input device 1260 can include, for example, a touch screen, a keyboard, etc. The user can input / output voice information through the loudspeaker 1270 and the microphone 1280.

[0070] In this embodiment, the memory 1220 of the terminal device 1200 is configured to store instructions for controlling the processor 1210 to operate to perform at least the method according to any embodiment of the present disclosure. The skilled person can design the instructions according to the disclosed solutions of the present disclosure. How the instructions control the processor to operate is known in the art and will not be described in detail here.

[0071] Although a plurality of devices of the terminal device 1200 are shown in Figure 1b , the present disclosure can only involve part of the devices, for example, the terminal device 1200 only involves the memory 1220, the processor 1210, and the display device 1250.

[0072] <application scenario>

[0073] The traditional dialogue system is implemented based on a sequence-to-sequence model, but for the court trial scene, it involves multiple roles of trial debate, such as judges, plaintiffs, defendants, plaintiff agents, defendant agents, plaintiff lawyers, and defendant lawyers. Because of the existence of multiple roles, any person in the multi-person dialogue can be questioned or stated, so each statement in the debate does not have a specific purpose.

[0074] The sequence-to-sequence model is limited to the timing relationship between statements, but for the dialogue, the words spoken by different roles may not have a timing relationship.

[0075] Figure 2 A schematic diagram of an application scenario of the multi-role dialogue method according to the embodiments of the present specification.

[0076] As Figure 2 shown, a plurality of roles input target statements to an electronic device executing the embodiments, the electronic device encodes each target statement into a corresponding syntax tree, encodes the role and the syntax tree to obtain an encoding vector, decodes the syntax tree and the encoding vector to obtain a reply statement, and displays or plays the reply statement, so that the electronic device can dialogue with the plurality of roles as a role, and can distinguish different roles and ask questions or answer different roles.

[0077] The multi-role dialogue method of the embodiments of the present specification can be applied to the judicial trial scene of the court, can be applied to the trial scene of labor arbitration, and can be applied to the registration or dispute mediation application scene of the civil affairs bureau.

[0078] <method embodiment>

[0079] In the present embodiment, a multi-role dialogue method is provided. The multi-role dialogue method can be implemented by an electronic device. The electronic device can be a server 1100 as Figure 1a shown, or a terminal device 1200 as Figure 1b shown.

[0080] According to Figure 3 shown, the multi-role dialogue method of the embodiments of the present specification can include the following steps S3100-S3400:

[0081] Step S3100, obtaining a plurality of target statements.

[0082] In the embodiment, the plurality of target sentences obtained can correspond to at least one role.

[0083] In the scenario where the plurality of target sentences correspond to a plurality of roles, that is, the plurality of target sentences are input by the plurality of roles, since the plurality of roles exist, the target sentence input by any one of the plurality of roles in the multi-role dialogue can be questioned or stated, and therefore, each target sentence is not targeted.

[0084] In an embodiment, the corresponding target voice can be input by each role, the target voice input by each role can be obtained by the electronic device executing the method of the embodiment through a microphone, and the target voice can be converted into text to obtain the target sentence.

[0085] In another embodiment, the corresponding target voice can also be input by each role, the target voice input by each role can be obtained by the sound pickup device through a microphone, and the target voice can be converted into text to obtain the target sentence. The target sentence can be provided to the electronic device executing the embodiment by the sound pickup device for obtaining by the electronic device.

[0086] In step S3200, each target sentence is encoded into a corresponding syntax tree.

[0087] In an embodiment of the present specification, each target sentence can be encoded by TreeLSTM respectively to obtain a corresponding syntax tree.

[0088] In the embodiment, the syntax tree can be used to describe the syntax structure of the target sentence. The syntax tree only has leaf nodes associated with the words in the input sentence, and other intermediate nodes are all labeled phrase components. The nouns used to label the phrase components can include ROOT, IP, NP, VP, PU, LCP, PP, CP, DNP, ADVP, ADJP, DP, QP, NN, NR, NT, PN, VV, VC, CC, VE, VA, AS, VRD, CD, DT, EX, FW, IN, JJ, JJR, JJS, LS, MD, PDT, POS, PRP, RB, RBR, RBS, RP, SYM, TO, WDT, WP, WP$, WRB, and the like.

[0089] where ROOT represents a sentence to be processed; IP represents a simple clause; NP represents a noun phrase; VP represents a verb phrase; PU represents a punctuation mark, usually a period, question mark, exclamation mark, and the like; LCP represents a locative phrase; PP represents a prepositional phrase; CP represents a phrase consisting of's' indicating a modifying relationship; DNP represents a phrase consisting of's' indicating a belonging relationship; ADVP represents an adverbial phrase; ADJP represents an adjective phrase; DP represents a determiner phrase; QP represents a quantifier phrase; NN represents a common noun; NR represents a proper noun; NT represents a time noun; PN represents a pronoun; VV represents a verb; VC represents is; CC represents a conjunction; VE represents has; VA represents a predicate adjective; AS represents a content marker (e.g., indicates that); VRD represents a verb-adverb combination; CD represents a cardinal number; DT represents a determiner; EX represents an existential there; FW represents a foreign word; IN represents a preposition or a subordinating conjunction; JJ represents an adjective or an ordinal numeral; JJR represents an adjective, comparative; JJS represents an adjective, superlative; LS represents a list item marker; MD represents a modal auxiliary; PDT represents a pre-determiner; POS represents a genitive marker; PRP represents a personal pronoun; RB represents an adverb; RBR represents an adverb, comparative; RBS represents an adverb, superlative; RP represents a particle; SYM represents a symbol; TO represents "to" as a preposition or an infinitive marker; WDT represents a WH-determiner; WP represents a WH-pronoun; WP$ represents a WH-pronoun, possessive; and WRB represents a Wh-adverb.

[0090] For example, the target sentence is "John has a dog.", and the syntax tree obtained by encoding the target sentence can be as followsFigure 4 as shown.

[0091] At step S3300, the role corresponding to each target sentence and the syntax tree are encoded to obtain an encoding vector.

[0092] In an embodiment of the present specification, before performing step S3300, the method can further include a step of determining the role corresponding to the target sentence, comprising:

[0093] Obtaining the role keyword in the target sentence; determining the role corresponding to each target sentence according to the role keyword.

[0094] The role keyword is a preset keyword reflecting the name of the corresponding role. For example, the role keyword can include plaintiff, defendant, plaintiff's lawyer, defendant's lawyer, plaintiff's agent, defendant's agent, judge, etc.

[0095] In one example, according to the input order, all target sentences between the target sentence containing the target role keyword and the target sentence containing the next role keyword (including the target sentence containing the target role keyword, but excluding the target sentence containing the next role keyword) are taken as the target sentence corresponding to the target role.

[0096] In another example, the pickup device corresponding to each role can also be preset, and the target voice uttered by the corresponding role is obtained by each pickup device. The target sentence corresponding to the role can be obtained by converting the target voice obtained by each pickup device into text by each pickup device; and the target sentence corresponding to the role is provided to the electronic device performing the embodiment by the pickup device, so that the electronic device obtains the target sentence. The target voice obtained by each pickup device can also be provided to the electronic device, and the target voice provided by each pickup device is converted into text by the electronic device to obtain the target sentence corresponding to the role.

[0097] In an embodiment of the present specification, the method can further include: in the case where the target sentence includes a specified keyword, performing step S3300 of the embodiment to encode the role corresponding to each target sentence and the syntax tree to obtain the encoding vector of each role. The specified keyword can be set in advance according to the application scenario or specific requirements. For example, in the judicial trial scene, the specified keyword can be "statement complete".

[0098] In an embodiment of the present specification, encoding the role corresponding to each target sentence and the syntax tree to obtain an encoding vector can include steps S3310-S3340 as shown below:

[0099] At step S3310, the role corresponding to each syntax tree is determined.

[0100] In this embodiment, the role corresponding to the syntax tree can be the same as the role corresponding to the target sentence coded as the syntax tree. For example, if the role corresponding to the target sentence is role A, then the role corresponding to the syntax tree of the target sentence is also role A.

[0101] In step S3320, the syntax trees corresponding to the same role are spliced to obtain the parent syntax tree of the same role.

[0102] Specifically, for each role, the syntax trees corresponding to the same role can be spliced under the corresponding root node in the order of the target sentences coded as the syntax trees to obtain the parent syntax tree of the same role.

[0103] In step S3330, the preset role word vector corresponding to the same role is fused with each syntax tree in the parent syntax tree to obtain the fused parent syntax tree of the same role.

[0104] Specifically, the role word vector of each role can be set according to the application scenario or specific requirements in advance. The role word vectors corresponding to different roles are different.

[0105] For any parent syntax tree, the role word vector of the corresponding role can be fused into each syntax tree to obtain the fused parent syntax tree.

[0106] In step S3340, the fused parent syntax tree of each role is encoded to obtain an encoding vector.

[0107] Specifically, the fused parent syntax tree of each role can be encoded based on a preset neural network to obtain the fused parent syntax tree vector of the corresponding role, and then the fused parent syntax tree vector is encoded according to a preset encoder to obtain an encoding vector.

[0108] The neural network in this embodiment can be a neural network Embedding that converts discrete variables into continuous vectors.

[0109] The encoder can be trained according to the application scenario or specific requirements in advance. Specifically, the encoder can encode the fused parent syntax tree vectors of all roles to obtain an encoding vector.

[0110] In step S3400, the syntax trees and the encoding vector are decoded to obtain a reply sentence of the multiple target sentences.

[0111] In one embodiment of the present specification, decoding the syntax trees and the encoding vector to obtain a reply sentence of the multiple target sentences can include steps S3410-S3430 as shown below:

[0112] Step S3410, for any target sentence, determining a correlation score between any two words in the syntax tree corresponding to the target sentence.

[0113] In an embodiment of the present disclosure, determining a correlation score between any two words in the syntax tree corresponding to the target sentence can include:

[0114] determining the distance between the two words in the syntax tree as the correlation score between the two words.

[0115] Specifically, in the syntax tree, each edge has a corresponding weight, and the distance between the nodes of two words in the syntax tree can be the sum of the weights of the edges connecting the nodes of the two words.

[0116] For example, in the example as shown in FIG. 4, the node of the word “John” is NNP, the node of the word “dog” is NN, and the edges connecting the node NNP and the node NN include the edge between the node NNP and the node NP, the edge between the node NP and the node S, the edge between the node S and the node VP, the edge between the node VP and the node NP, and the edge between the node NP and the node NN. Then, the correlation score between the words “John” and “dog” can be the sum of the weights of all the edges connecting the node NNP and the node NN. Figure 4

[0117] For another example, in the example as shown in FIG. 5, the node of the word “has” is VBZ, the node of the word “dog” is NN, and the edges connecting the node VBZ and the node NN include the edge between the node VBZ and the node VP, the edge between the node VP and the node NP, and the edge between the node NP and the node NN. Then, the correlation score between the words “has” and “dog” can be the sum of the weights of all the edges connecting the node VBZ and the node NN. Figure 4

[0118] In an embodiment of the present disclosure, the correlation score between any two words in the syntax tree corresponding to each target sentence can be determined respectively.

[0119] Step S3420, generating a correlation score matrix according to the correlation scores.

[0120] In the case where the target sentence contains N words, the words corresponding to the ith (i is a positive integer less than or equal to N) row and the ith column in the correlation score matrix are the same, and the words corresponding to the ith row are the words in the ith word order in the target sentence.

[0121] ​​In an embodiment of the present disclosure, the step S3410 or the steps S3410-S3420 can be performed after the step S3200 is performed, before the step S3300 is performed, during the step S3300 is performed, or after the step S3300 is performed. The embodiment does not limit the execution order of the steps.

[0122] The step S3430 decodes the related score matrix and the encoding vector to obtain a reply statement of the target statement.

[0123] In an embodiment of the present disclosure, the decoding of the related score matrix and the encoding vector to obtain the reply statement of the target statement can include the steps S3431-S3434 as shown below.

[0124] The step S3431 linearly transforms the related score matrix of the plurality of target statements to obtain a score tensor.

[0125] A tensor is a multilinear function that can be used to represent a linear relationship between some vectors, scalars, and other tensors.

[0126] The step S3432 performs a weighted transformation on the encoding vector through an attention mechanism to obtain an output tensor.

[0127] The attention mechanism has a huge promotion effect on a sequence learning task. In a framework of an encoder-decoder, an attention model is added to the encoder or the decoder to perform a data weighted transformation on the encoding vector, which can effectively improve the system performance in a natural way of sequence to sequence.

[0128] Specifically, the attention model can be trained in advance. The trained attention model can perform a weighted transformation on the encoding vector through the attention mechanism to obtain the output tensor.

[0129] The step S3433 performs a splicing processing on the score tensor and the output tensor to obtain a spliced tensor.

[0130] The step S3434 decodes the spliced tensor to obtain the reply statement.

[0131] Specifically, the spliced tensor can be decoded based on a pre-trained decoder to obtain the reply statement.

[0132] In an embodiment of the present specification, a target sentence input by at least one role is encoded into a corresponding syntax tree, an encoding vector is obtained according to the role and the syntax tree, and a reply sentence is obtained by decoding according to the syntax tree and the encoding vector. By adopting the syntax tree structure, the syntax tree of each role is distinguished, instead of simply splicing all sentences together. In this way, different roles can be distinguished, and questions or answers can be asked or given for different roles.

[0133] In an embodiment of the present specification, after obtaining the reply sentence, the method can further include: playing the reply sentence; and / or, displaying the reply sentence. In this way, the electronic device executing the embodiment of the present specification can have a conversation with the at least one role inputting the target sentence as another role.

[0134] <Device Embodiment>

[0135] In the present embodiment, a multi-role conversation device 5000 is provided, as shown in the figure, comprising a sentence acquisition module 5100, a syntax tree generation module 5200, an encoding module 5300 and a decoding module 5400. The sentence acquisition module 5100 is configured to acquire a plurality of target sentences; wherein the plurality of target sentences correspond to at least one role; the syntax tree generation module 5200 is configured to encode each target sentence into a corresponding syntax tree; the encoding module 5300 is configured to encode according to the role and the syntax tree corresponding to each target sentence to obtain an encoding vector; and the decoding module 5400 is configured to decode according to the syntax tree and the encoding vector to obtain a reply sentence of the plurality of target sentences. Figure 5

[0136] In an embodiment of the present specification, the encoding module 5300 can be further configured to:

[0137] determine the role corresponding to each syntax tree;

[0138] splice the syntax trees corresponding to the same role to obtain a parent syntax tree of the same role;

[0139] fuse the preset role word vector corresponding to the same role with each syntax tree in the parent syntax tree to obtain a fused parent syntax tree of the same role;

[0140] encode the fused parent syntax tree of each role respectively to obtain the encoding vector.

[0141] In an embodiment of the present specification, the decoding module 5400 can be further configured to:

[0142] for any target sentence, determine a correlation score between any two words in the syntax tree corresponding to the target sentence;

[0143] generate a correlation score matrix according to the correlation scores; ​

[0144] According to the correlation score matrix and the encoding vector, a reply statement of the target statement is obtained.

[0145] In an embodiment of the present disclosure, determining the correlation score between any two words in the syntax tree corresponding to the target statement comprises:

[0146] Determining the distance between the two words in the syntax tree corresponding to the target statement as the correlation score between the two words.

[0147] In an embodiment of the present disclosure, according to the correlation score matrix and the encoding vector, a reply statement of the target statement is obtained, comprising:

[0148] Linearly transforming the correlation score matrices of a plurality of target statements to obtain a score tensor;

[0149] The encoding vector is weighted and transformed through an attention mechanism to obtain an output tensor;

[0150] The score tensor and the output tensor are spliced to obtain a spliced tensor;

[0151] The spliced tensor is decoded to obtain a reply statement.

[0152] In an embodiment of the present disclosure, further comprising a module for determining the role corresponding to the target statement, for:

[0153] Obtaining a role keyword in the target statement; wherein the role keyword is a preset keyword reflecting the name of the corresponding role;

[0154] Determining the role corresponding to the target statement according to the role keyword.

[0155] In an embodiment of the present disclosure, the encoding module 5300 can also be used to perform the step of encoding according to the role corresponding to each target statement and the parent syntax tree to obtain the encoding vector of each role when the target statement includes a specified keyword.

[0156] In an embodiment of the present disclosure, further comprising:

[0157] A module for playing the reply statement; and / or,

[0158] A module for displaying the reply statement.

[0159] Those skilled in the art will understand that the multi-role dialogue device 5000 can be implemented in various ways. For example, the multi-role dialogue device 5000 can be implemented by configuring a processor with instructions. For example, the instructions can be stored in ROM, and when the device is started, the instructions can be read from ROM into a programmable device to implement the multi-role dialogue device 5000. For example, the multi-role dialogue device 5000 can be embedded in a dedicated device (e.g., an ASIC). The multi-role dialogue device 5000 can be divided into independent units, or they can be combined together. The multi-role dialogue device 5000 can be implemented by one of the various implementation methods described above, or by a combination of two or more of the various implementation methods described above.

[0160] In this embodiment, the multi-role dialogue device 5000 can have various implementation forms. For example, the multi-role dialogue device 5000 can be any functional module running in a software product or application that provides processing services, or a peripheral embedding, plug-in, patch, etc. of such software products or applications, or it can be the software products or applications themselves.

[0161] In the embodiments of this specification, the target statement input by at least one role is encoded into a corresponding syntax tree. An encoding vector is obtained by encoding based on the role and the syntax tree. Then, the response statement is obtained by decoding based on the syntax tree and the encoding vector. By employing a syntax tree structure, the syntax tree of each role is distinguished, rather than simply concatenating all statements. This allows for differentiation between different roles, enabling questions or answers to be tailored to specific roles.

[0162] <Electronic Devices>

[0163] In this embodiment, an electronic device 1000 is also provided. The electronic device 1000 may be... Figure 1a The server shown is 1100 or as shown Figure 1b The terminal device shown is 1200.

[0164] like Figure 6 As shown, the electronic device 1000 may further include a processor 1300 and a memory 1400, the memory 1400 being used to store executable instructions; the processor 1300 being used to control the electronic device 1000 to execute a multi-role dialogue method according to any embodiment of the present disclosure, as controlled by the instructions.

[0165] For example, electronic device 1000 could be a computer cluster capable of providing multi-role dialogue services.

[0166] In the embodiments of the present disclosure, a target sentence input by at least one role is encoded into a corresponding syntax tree, an encoding vector is obtained according to the role and the syntax tree, and a reply sentence is obtained by decoding according to the syntax tree and the encoding vector. By adopting the syntax tree structure, the syntax tree of each role is distinguished, instead of simply splicing all sentences together. In this way, different roles can be distinguished, and questions or answers can be made for different roles.

[0167] <Computer-readable storage medium>

[0168] In the embodiments of the present disclosure, a computer-readable storage medium is also provided, which stores a computer program. The computer program, when executed by a processor, implements the multi-role dialogue method of any embodiment of the present disclosure.

[0169] The present disclosure can be a system, a method, and / or a computer program product. The computer program product can include a computer readable storage medium (media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present disclosure.

[0170] The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium can be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium include the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch cards or punched tape, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.

[0171] Computer readable program instructions described herein can be downloaded to respective computing / processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and / or a wireless network. The network can comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and / or edge servers. A network adapter card or network interface in each computing / processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing / processing device.

[0172] Computer readable program instructions for carrying out operations of the present disclosure can be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, for example, through the Internet using an Internet Service Provider. In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) can execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present disclosure.

[0173] The computer readable program instructions can also be loaded onto a computing / processing device, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computing / processing device, other programmable apparatus or other device to produce a computer implemented process such that the instructions which execute on the computing / processing device, other programmable apparatus, or other device implement the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0174] These computer readable program instructions can be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions / acts specified in the flowchart and / or block diagram block or blocks. These computer readable program instructions can also be stored in a computer readable storage medium that can include a non-transitory computer readable storage medium that can be a computer- readable storage medium having no data, programs, program modules, e.g., instructions for operation, or digital content stored thereon or therein for a short time or not at all. The computer readable storage medium can also have instructions stored thereon or therein which may

[0175] The computer readable program instructions can also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable data processing apparatus, or other device implement the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0176] The flow diagrams and the block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams and the block diagrams can represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logic functions. In some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in some cases, be executed substantially concurrently, or the blocks can sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and / or flowchart illustrations, and combinations thereof, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and

[0177] Having described above several embodiments of the disclosure, any modifications and variations that fall within the scope of the described embodiments are also contemplated by the inventor(s). As such, the foregoing description is not intended to limit the scope of the disclosure, and it is recognized that modifications are contemplated which can provide one or more benefits and which are within the scope of the disclosure. The disclosure is defined by the appended claims.

Claims

1.A multi-role dialogue method, comprising: obtaining a plurality of target sentences, wherein the plurality of target sentences correspond to at least one role; encoding each target sentence into a corresponding syntax tree; encoding according to the role and the syntax tree corresponding to each target sentence to obtain an encoding vector, wherein the encoding vector is obtained by fusing a parent syntax tree corresponding to different roles and a preset role word vector, and the parent syntax tree is obtained by splicing the syntax trees corresponding to the roles; decoding according to the syntax tree and the encoding vector to obtain a reply sentence of the plurality of target sentences. 2.The method of claim 1, wherein the encoding according to the role and the syntax tree corresponding to each target sentence to obtain an encoding vector comprises: determining the role corresponding to each syntax tree; splicing the syntax trees corresponding to the same role to obtain a parent syntax tree of the same role; fusing the preset role word vector corresponding to the same role with each syntax tree in the parent syntax tree to obtain a fused parent syntax tree of the same role; and encoding the fused parent syntax tree of each role respectively to obtain an encoding vector. 3.The method of claim 1, wherein the decoding according to the syntax tree and the encoding vector to obtain a reply sentence of the plurality of target sentences comprises: for any target sentence, determining a correlation score between any two words in the syntax tree corresponding to the target sentence; generating a correlation score matrix according to the correlation score; decoding according to the correlation score matrix and the encoding vector to obtain a reply sentence of the target sentence. 4.The method of claim 3, wherein the determining a correlation score between any two words in the syntax tree corresponding to the target sentence comprises: determining the distance between the any two words in the syntax tree corresponding to the target sentence as the correlation score of the any two words. 5.The method of claim 3, wherein the decoding according to the correlation score matrix and the encoding vector to obtain a reply sentence of the target sentence comprises: performing linear transformation on the correlation score matrix of the plurality of target sentences to obtain a score tensor; performing weighted transformation on the encoding vector through an attention mechanism to obtain an output tensor; performing splicing processing on the score tensor and the output tensor to obtain a splicing tensor; and decoding the splicing tensor to obtain the reply sentence. 6.The method of claim 1, wherein the role corresponding to the target sentence is determined by: obtaining a role keyword in the target sentence, wherein the role keyword is a preset keyword reflecting the name of the corresponding role; and determining the role corresponding to the target sentence according to the role keyword. 7.A multi-role dialogue device, comprising: a sentence obtaining module configured to obtain a plurality of target sentences, wherein the plurality of target sentences correspond to at least one role; a syntax tree generating module configured to encode each target sentence into a corresponding syntax tree; and an encoding module configured to encode according to the role and the syntax tree corresponding to each target sentence to obtain an encoding vector, wherein the encoding vector is obtained by fusing a parent syntax tree corresponding to different roles and a preset role word vector, and the parent syntax tree is obtained by splicing the syntax trees corresponding to the roles. The encoding module is configured to encode according to the role corresponding to each target sentence and the syntax tree to obtain an encoding vector, wherein the encoding vector is obtained by encoding after fusing a parent syntax tree corresponding to different roles and a preset role word vector, and the parent syntax tree is obtained by splicing the syntax trees corresponding to the roles; The decoding module is configured to decode according to the syntax tree and the encoding vector to obtain a reply sentence of the plurality of target sentences. 8.An electronic device, comprising: a processor and a memory, the memory being configured to store instructions for controlling the processor to perform the method according to any one of claims 1 to 6. 9.A computer-readable storage medium having stored thereon a computer program, the computer program, when executed by a processor, implementing the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • A method for analyzing a sentence semantic structure and related equipment

    CN109408628A

  • Intelligent dialogue method and device and electronic equipment

    CN111444329A