A method and device for identifying topics in a dialogue system using contextual information
By building a slot library and a dialogue slot table and combining context information for topic identification, the problem of low single-sentence recognition accuracy in the existing technology is solved, and higher recognition accuracy and adaptability are achieved.
Patent Information
- Application Number
- CN202210061311.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-19
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-01-19
AI Technical Summary
In the existing technology, topic recognition in human-computer dialogue systems relies solely on single sentence information, resulting in information loss and misrecognition. In particular, contextual information is not fully utilized in medical dialogues, resulting in low recognition accuracy.
Build a slot library and a dialogue slot table, combine context information for topic identification, predict sentence topics through named entity recognition and deep learning models, and determine the final topic by matching the slot library with the dialogue slot table.
The accuracy of topic identification is improved, information loss and misidentification are avoided, and the practicality and adaptability of the method are enhanced to adapt to different dialogue environments.
Smart Images

Figure CN114791949B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of topic identification, and in particular to a method and device for topic identification in a dialogue system combining context information. Background Art
[0002] Human-computer dialogue systems are a key application of speech recognition technology in practical applications. They enable computers to identify the thoughts expressed by humans through natural speech. Topic identification is a crucial component of dialogue systems. Its primary function is to utilize various machine learning and deep learning methods to identify and classify input sentences, identifying their specific category within a given topic category and thereby determining the specific topic of the sentence. Topic identification is commonly performed using discriminative or generative models such as DNNs, convolutional neural networks, and bidirectional LSTMs.
[0003] Typically, topic identification only focuses on the current sentence, which can easily lead to information loss and, due to the black-box nature of the model, can lead to erroneous jumps. For example, in a medical conversation, if a visitor's previous question, "Can I work on Project A?", is correctly identified as Topic A, then in the subsequent conversation, if there's no explicit mention of Topic A or if information shared by Topic A and other topics is described, it may not be identified or may be incorrectly identified. Traditional topic identification can only identify individual sentences, ignoring the topic information contained in the context. This results in low accuracy and poor recognition results.
[0004] In view of this, proposing a topic identification method that can combine contextual information is one of the important issues that needs to be solved urgently. Summary of the Invention
[0005] In response to the aforementioned problems such as low accuracy in identifying the topic of a single sentence, the embodiment of the present application aims to propose a method and apparatus for identifying the topic of a dialogue system in combination with context information to solve the technical problems mentioned in the above background technology section.
[0006] In a first aspect, an embodiment of the present application provides a method for identifying topics in a dialogue system in combination with context information, comprising the following steps:
[0007] S1, obtain the topic dataset, and build a slot library with multiple rows of slots according to the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence;
[0008] S2, pre-processing the current sentence of the dialogue to be recognized in the dialogue system and inputting it into the trained single-sentence topic recognition model to predict the first topic of the current sentence and its corresponding prediction probability value;
[0009] S3, identify all entities in the current sentence and all previous sentences, and build a dialogue slot table based on all entities and their categories in the current sentence. The entity categories in the slot library include the entity categories in the dialogue slot table;
[0010] S4, determining a second topic of the current sentence and its corresponding matching probability value in response to the number of successful matches of the dialog slot table in the slot library;
[0011] S5 , in response to the topic corresponding to the larger one of the predicted probability value and the matching probability value being the first topic or the second topic, determining it as the topic of the current sentence.
[0012] In some embodiments, step S1 constructs a slot library having multiple rows of slots based on the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence, specifically including:
[0013] S11, using named entity recognition to identify the entities of each sentence in the topic dataset;
[0014] S12, obtain each row of slots in the slot library according to the topic of each sentence and the entities of each category identified;
[0015] S13, repeat steps S11-S12 to obtain a slot library corresponding to multiple sentences in the topic dataset.
[0016] In some embodiments, the preprocessing process of each sentence in the dialogue system specifically includes:
[0017] Use the Jieba word segmenter to segment each sentence and obtain at least one word in each sentence;
[0018] Use Word2vec to process each word and obtain word vector embedding representation;
[0019] The word vector embedding representations of each sentence are concatenated to obtain a merge matrix.
[0020] In some embodiments, the single-sentence topic identification model is a text classification model based on machine learning, and the single-sentence topic identification model includes at least a fully connected layer and a softmax layer.
[0021] In some embodiments, the training process of the single-sentence topic identification model includes:
[0022] Preprocess each sentence in the topic dataset to obtain a merge matrix;
[0023] Use one-hot encoding to encode the topics in the topic dataset into the first vector of 1*n dimension;
[0024] Input the merged matrix into the fully connected layer and the softmax layer to obtain the second vector;
[0025] Calculate the cross entropy loss function between the second vector and the first vector, and iteratively optimize the parameters of the single-sentence topic identification model step by step.
[0026] In some embodiments, step S4 further includes:
[0027] S41: Determine whether the conversation slot table is empty. If so, directly use the first topic as the topic of the current sentence. Otherwise, construct entity pairs between entities of different categories in the conversation slot table, and match the entity pairs in the conversation slot table in the slot library.
[0028] S42, if one of the entity pairs in the conversation slot table is the same as the entity in one row of slots in the slot library, the match is successful, and the third topic corresponding to the entity in one row of slots in the slot library is recorded;
[0029] S43, repeat step S42 to match the conversation slot table with the slot library, and obtain the total number of successful matches of the conversation slot table in the slot library and the number of successful matches of at least one third topic and its corresponding topic.
[0030] In some embodiments, step S4 specifically includes:
[0031] The third topic with the highest number of successful matches among the number of successful matches corresponding to the at least one third topic is used as the second topic;
[0032] The matching probability value is obtained by dividing the highest number of successful matches among the number of successful matches corresponding to at least one third topic by the total number of successful matches in the dialogue slot table in the slot library.
[0033] In some embodiments, the method further includes: adding, deleting or modifying slots in the slot library, and repeating steps S2-S5 to adjust the recognition effect of the subject of the current sentence.
[0034] In a second aspect, an embodiment of the present application provides a conversation system topic identification device incorporating context information, including:
[0035] A slot library construction module is configured to obtain a topic dataset and construct a slot library with multiple rows of slots according to the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence;
[0036] A topic prediction module is configured to pre-process the current sentence of the dialogue to be recognized in the dialogue system and input it into the trained single-sentence topic recognition model to predict the first topic of the current sentence and its corresponding prediction probability value;
[0037] A dialogue slot table building module is configured to identify all entities in a current sentence and all previous sentences, and to build a dialogue slot table based on all entities and their categories in the current sentence, wherein the entity categories in the slot library include the entity categories in the dialogue slot table;
[0038] a matching module configured to determine a second topic of the current sentence and a corresponding matching probability value thereof in response to a number of successful matches of the dialog slot table in the slot library;
[0039] The topic determination module is configured to determine the topic of the current sentence in response to the topic corresponding to the larger one of the predicted probability value and the matching probability value being the first topic or the second topic.
[0040] In a third aspect, an embodiment of the present application provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.
[0041] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.
[0042] Compared with the prior art, the present invention has the following beneficial effects:
[0043] (1) The present invention proposes a method and device for identifying topics in a dialogue system in combination with context information, which combines context information by constructing a slot library and a dialogue slot table to avoid problems such as topic identification errors caused by information loss.
[0044] (2) The single-sentence topic identification model used in the dialogue system topic identification method and device combined with context information proposed by the present invention does not have strict requirements and restrictions, which increases the practicality and adaptability of the method.
[0045] (3) The present invention proposes a method and device for identifying topics in a dialogue system in combination with contextual information. The method and device can adjust the effect of topic identification by adding or deleting content in the slot library to adapt to different dialogue environments and effectively improve the accuracy of identification. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0047] Figure 1 is a diagram of an exemplary device architecture to which an embodiment of the present application may be applied;
[0048] Figure 2 A flowchart of a method for identifying a topic in a dialogue system incorporating contextual information according to an embodiment of the present invention;
[0049] Figure 3 A schematic diagram of a conversation system topic identification device combining context information according to an embodiment of the present invention;
[0050] Figure 4 It is a structural diagram of a computer device suitable for implementing the electronic device of the embodiment of the present application. DETAILED DESCRIPTION
[0051] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It is apparent that the embodiments described are only some, not all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort are intended to fall within the scope of protection of the present invention.
[0052] Figure 1 An exemplary device architecture 100 is shown to which the method for identifying topics in a dialogue system in combination with context information or the device for identifying topics in a dialogue system in combination with context information according to an embodiment of the present application can be applied.
[0053] like Figure 1 As shown, the device architecture 100 may include terminal devices 101, 102, 103, a network 104, and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired or wireless communication links or fiber optic cables.
[0054] Users can use terminal devices 101, 102, 103 to interact with server 105 via network 104 to receive or send messages, etc. Various applications, such as data processing applications and file processing applications, can be installed on terminal devices 101, 102, 103.
[0055] Terminal devices 101, 102, and 103 can be hardware or software. When terminal devices 101, 102, and 103 are hardware, they can be various electronic devices, including but not limited to smartphones, tablet computers, laptop computers, and desktop computers. When terminal devices 101, 102, and 103 are software, they can be installed in the electronic devices listed above. They can be implemented as multiple software or software modules (for example, software or software modules used to provide distributed services), or they can be implemented as a single software or software module. No specific limitations are given here.
[0056] The server 105 may be a server that provides various services, such as a background data processing server that processes files or data uploaded by the terminal devices 101, 102, and 103. The background data processing server may process the acquired files or data and generate processing results.
[0057] It should be noted that the dialogue system topic identification method combined with context information provided in the embodiment of the present application can be executed by the server 105, or by the terminal devices 101, 102, and 103. Accordingly, the dialogue system topic identification device combined with context information can be set in the server 105, or in the terminal devices 101, 102, and 103.
[0058] It should be understood that Figure 1 The number of terminal devices, networks, and servers in the above description is merely illustrative. Any number of terminal devices, networks, and servers may be provided as needed. If the processed data does not need to be acquired remotely, the above-described apparatus architecture may not include a network, but only require servers or terminal devices.
[0059] Figure 2 A method for identifying topics in a dialogue system using contextual information is provided in an embodiment of the present application, and includes the following steps:
[0060] S1, obtain the topic dataset, and build a slot library with multiple rows of slots according to the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence.
[0061] Specifically, a topic dataset is a dataset obtained by subjecting text extracted from a dialogue system to single-sentence topic annotation. Each sentence in the topic dataset is annotated with a corresponding topic; that is, each sentence corresponds to a topic, which is considered an annotated topic. The text extracted from the dialogue system can be selected from a large amount of medical conversation log data, generated by visitors. A topic dataset generally consists of multiple data items, each of which is a sentence-to-topic mapping, such as "How much does double eyelid surgery cost?" When constructing a slot database, only one row of slot data is generated for each sentence. Based on the topic corresponding to each sentence in the topic database, the relationship between the topic in the corresponding slot and different entity categories can be found in the slot database. The first row of the slot database contains the topic and different entity categories. The slot database, composed of multiple sentences from the topic dataset, is a table of general significance. It contains the relationship features between each sentence, its corresponding topic, and the entities in each sentence, facilitating table lookups to find corresponding topics. The slot database also contains contextual information from the topic dataset. The slot database serves as a pre-storage of contextual information, while the conversation slot table temporarily stores matching information during the recognition process. The topic dataset is not only an important source of information for the slot library, but can also be used to train single-sentence topic recognition models. To ensure that the trained single-sentence topic recognition model performs well in classification tasks, the topic dataset must be sufficient. Based on experience, the topic dataset should be at least 1,000 times the number of topic categories, and the distribution of topic data across categories should be relatively balanced. Therefore, the topic dataset is derived from a dataset composed of sentences from actual conversations and contains a balanced mix of all defined topics. In this case, the trained single-sentence topic recognition model will produce more accurate results.
[0062] In a specific embodiment, step S1 constructs a slot library with multiple rows of slots based on the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence, specifically including:
[0063] S11, identifying entities of each sentence in the subject dataset using named entity recognition;
[0064] S12, obtain each row of slots in the slot library according to the topic of each sentence and the entities of each category identified;
[0065] S13, repeating steps S11-S12 to obtain a slot library corresponding to multiple sentences in the topic dataset.
[0066] Specifically, named entity recognition (NER) is an important basic tool in application fields such as information extraction, question-answering systems, syntactic analysis, and machine translation, and plays an important role in the practical application of natural language processing technology. Generally speaking, the task of named entity recognition is to identify three major categories (entity category, time category, and number category) and seven subcategories (personal name, institution name, place name, time, date, currency, and percentage) of named entities in the text to be processed. Taking one of the tasks in medical dialogue as an example, NER needs to identify entities in five categories: symptoms, parts, technology, materials, and instruments. The constructed slot library is shown in Table 1:
[0067] Table 1 Slot library example table
[0068] theme symptom Part technology Material instrument Double eyelids single eyelids cut Double eyelids Eye Incision Double eyelids Eye Thread embedding .... .... .... .... .... .... Hyaluronic acid rhinoplasty nose injection Hyaluronic acid .... .... .... .... .... .... Laser hair removal hairy Laser instruments .... .... .... .... .... ....
[0069] According to the above table, a corresponding relationship is established between the subjects in the above slot library and entities under the five categories of symptoms, parts, techniques, materials, and instruments.
[0070] In a specific embodiment, before a topic dataset in a dialogue system is used to train a single-sentence topic identification model, each sentence in the topic dataset needs to be preprocessed. The current sentence of a dialogue to be identified in the dialogue system also needs to be preprocessed before being input into the trained single-sentence topic identification model for prediction. The preprocessing process for each sentence in the dialogue system specifically includes:
[0071] Use the Jieba word segmenter to segment each sentence and obtain at least one word in each sentence;
[0072] Use Word2vec to process each word and obtain word vector embedding representation;
[0073] The word vector embedding representations of each sentence are concatenated to obtain a merge matrix.
[0074] For example, the sentence "How much does plastic surgery cost?" is segmented into two words: [Plastic surgery, how much] These two words are embedded using Word2vec, yielding two vectors, v1 and v2. Both v1 and v2 are 1*n word embeddings, where n is the fixed dimension of Word2vec. v1 and v2 are then concatenated vertically to form a 2*n concatenation matrix A = [v1; v2]. When a sentence contains multiple words, a maximum number m is predefined. Excessive words are discarded, and vectors are padded with zeros. The concatenation is performed using the above method to form an m*n concatenation matrix. This concatenation matrix can be used as input for a single-sentence topic identification model. In deep learning, embedding refers to embedding low-dimensional raw data into a high-dimensional space. In natural language processing, it involves encoding text into vectors in a high-dimensional space for computational purposes. Common embedding methods include Onehot, Word2vec, Glove, Elmo, and Bert.
[0075] In a specific embodiment, the single-sentence topic identification model is a machine learning-based text classification model that includes at least a fully connected layer and a softmax layer. The network structure of the single-sentence topic identification model is not restricted and can be any model commonly used for classification tasks, such as CNN, RNN, LSTM, GRU, Transformer, etc. Therefore, there are relatively few restrictions on the network structure and it is applicable to a variety of single-sentence topic identification models.
[0076] In a specific embodiment, the training process of the single-sentence topic identification model includes:
[0077] Preprocess each sentence in the topic dataset to obtain a merge matrix;
[0078] Use one-hot encoding to encode the topics in the topic dataset into the first vector of 1*n dimension;
[0079] Input the merged matrix into the fully connected layer and the softmax layer to obtain the second vector;
[0080] Calculate the cross entropy loss function between the second vector and the first vector, and iteratively optimize the parameters of the single-sentence topic identification model step by step.
[0081] Specifically, for the topic category of each row in the topic dataset, one-hot encoding is used to encode the topic into a first vector of 1*n dimension, which is a 01 vector consisting of 0s and 1s. The merged matrix is input into the fully connected layer, and the output is a third vector of 1*n dimension. The third vector is input into the softmax layer for normalization, and the normalized vector is output as the second vector. The cross entropy of the second vector and the first vector is calculated. After gradual iterative optimization, a trained single-sentence topic recognition model is obtained.
[0082] S2, pre-processing the current sentence of the dialogue to be recognized in the dialogue system and inputting it into the trained single-sentence topic recognition model, predicting the first topic of the current sentence of the dialogue to be recognized, and obtaining the predicted probability value corresponding to the first topic.
[0083] Specifically, the current sentence of the dialogue to be recognized in the dialogue system is preprocessed to obtain a merged matrix A', and the merged matrix A' is input into the trained single-sentence topic recognition model to predict the first topic corresponding to the current sentence, and the predicted probability value P1 that the current sentence is predicted to be the first topic can also be obtained.
[0084] S3, identifies all entities in the current sentence and all previous sentences, and establishes a dialogue slot table based on all entities and their categories in the current sentence. The entity categories in the slot library include the entity categories in the dialogue slot table.
[0085] Specifically, a conversation slot table is constructed, with entity categories as the first row. The entity categories in the slot library include those in the conversation slot table. In a preferred embodiment, the entity categories in the conversation slot table are identical to those in the slot library. In other embodiments, the entity categories in the conversation slot table are identical to at least one of the entity categories in the slot library, facilitating matching of subsequent conversation slot tables with the slot library. Similarly, NER is used to identify all entities in the current sentence and store them according to their categories in the conversation slot table, thereby establishing a conversation slot table corresponding to the current sentence. The conversation slot table stores all slot information that has occurred in the conversation up to the current moment. Each entity category may contain multiple entity values. During the matching process with the slot library, multiple entity values in one entity category require multiple entity values in another entity category to form entity pairs that are matched with the slots in the slot library. The following uses a medical conversation as an example to illustrate the format of the conversation slot table.
[0086] For example, the current sentence is: My eyes are relatively small, and I would like to ask which is better, the inner incision double eyelid or the buried suture double eyelid?
[0087] The dialogue slot table obtained based on the above current sentence is shown in Table 2.
[0088] Table 2 Dialogue slot table
[0089] symptom Part technology Material instrument Eye Internal incision, thread embedding
[0090] According to the conversation slot table in Table 2, two sets of entity pairs can be constructed based on different entity categories: one for "eyes, incision" and the other for "eyes, thread embedding." Because each row in the slot library represents a relationship between a different entity category and the topic, entities of the same category in the conversation slot table cannot form an entity pair. The conversation slot table constructs two sets of entity pairs based on different entity categories to facilitate matching with the slot library.
[0091] S4, in response to the number of successful matches of the dialog slot table in the slot library, determining the second topic of the current sentence and its corresponding matching probability value.
[0092] In a specific embodiment, step S4 further includes:
[0093] S41: Determine whether the conversation slot table is empty. If so, directly use the first topic as the topic of the current sentence. Otherwise, construct entity pairs between entities of different categories in the conversation slot table, and match the entity pairs in the conversation slot table in the slot library.
[0094] S42, if one of the entity pairs in the conversation slot table is the same as an entity in one row of the slot library, the match is successful, and the third topic corresponding to the entity in one row of the slot library is recorded;
[0095] S43, repeat step S42 to match the conversation slot table with the slot library, and obtain the total number of successful matches of the conversation slot table in the slot library and the number of successful matches of at least one third topic and its corresponding topic.
[0096] Specifically, the case where the conversation slot table in step S41 is empty means that the current sentence and all sentences before the current sentence do not contain any entity. This usually occurs when effective communication has not yet taken place at the beginning of the conversation. For example, the sentence that starts the conversation is "Hello". In this case, topic A1 is generally identified as "no topic", so the first topic of the current sentence predicted by the trained single-sentence topic recognition model is directly returned.
[0097] For example, the conversation content is:
[0098] Visitor: I want to consult about beauty.
[0099] At this point, the conversation slot table is empty.
[0100] Visitor: I would like to consult about eye beauty.
[0101] At this time, the conversation slot table is shown in Table 3:
[0102] Table 3
[0103] symptom Part technology Material instrument Eye
[0104] If the conversation slot table is not empty, it means that an entity has been recognized from the current conversation. The data in the conversation slot table is then matched against the slot library. If the values in the slots corresponding to a row in the slot library are all present in the conversation slot storage table, the topic corresponding to that row is successfully matched with the current sentence. Because each topic has multiple rows in the slot library, each topic can be successfully matched multiple times.
[0105] The matching process of the dialog slot table in Table 2 in the slot library is shown in Table 4:
[0106] Table 4
[0107]
[0108]
[0109] As shown in Table 3, the conversation slot table in Table 2 successfully matches the slot library twice, and the third subject that successfully matches both times is double eyelids. This means that the slots corresponding to the second and third rows of Table 3 are successfully matched in the conversation slot table. Incorporating contextual information is more important in enabling contextual table lookup during application, rather than traditional single-sentence recognition.
[0110] Specifically, the conversation slot table is built based on the current sentence and the sentences preceding it. With each incoming sentence, the table is updated to obtain a conversation slot table with contextual information and accurately match it within the slot library. The above method is used to construct a conversation slot table for each sentence in the dialogue system to be recognized, and the conversation slot table is matched against the slot library. All successfully matched third topics are counted, and the number of successful matches for each third topic is recorded. Finally, the number of successful matches for all third topics is summarized.
[0111] In a specific embodiment, step S4 specifically includes:
[0112] The third topic with the highest number of successful matches among the number of successful matches corresponding to the at least one third topic is used as the second topic;
[0113] The matching probability value is obtained by dividing the highest number of successful matches among the number of successful matches corresponding to at least one third topic by the total number of successful matches in the dialogue slot table in the slot library.
[0114] In a specific embodiment, assuming that all third topics are successfully matched 10 times, of which topic X is matched 7 times, topic Y is matched 2 times, and topic Z is matched 1 time, topic X with the highest number of successful matches is selected as the second topic, and its matching probability value P2 is 7 / 10.
[0115] S5 , in response to the topic corresponding to the larger one of the predicted probability value and the matching probability value being the first topic or the second topic, determining it as the topic of the current sentence.
[0116] Specifically, the predicted probability value is compared with the matching probability value, and the topic corresponding to the larger probability value is determined as the topic of the current sentence. The predicted probability value P1 is compared with the matching probability value P2, and the topic corresponding to the larger value is selected as the topic output of the current sentence. If the predicted probability value P1 is larger, the first topic is output as the topic of the current sentence; if the matching probability value P2 is larger, the second topic is output as the topic of the current sentence.
[0117] In a specific embodiment, the method further includes: adding, deleting or modifying slots in the slot library, and repeating steps S2-S5 to adjust the recognition effect of the topic of the current sentence.
[0118] Specifically, when necessary, the recognition results can be redirected by manually adding, deleting, or modifying the data in the slot library to better adjust the recognition effect of the current sentence's topic and obtain more accurate recognition results. The present invention can combine the above information for topic recognition, thereby avoiding the problem of information loss and recognition errors.
[0119] Further references Figure 3 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a conversation system topic identification device that combines context information. Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0120] The present application provides a conversation system topic identification device that combines context information, including:
[0121] The slot library construction module 1 is configured to obtain a topic dataset and construct a slot library with multiple rows of slots according to the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence;
[0122] Topic prediction module 2 is configured to pre-process the current sentence of the dialogue to be recognized in the dialogue system and input it into the trained single-sentence topic recognition model to predict the first topic of the current sentence of the dialogue to be recognized and obtain a predicted probability value corresponding to the first topic;
[0123] A dialogue slot table building module 3 is configured to identify all entities in the current sentence and all previous sentences, and to build a dialogue slot table based on all entities and their categories in the current sentence, where the entity categories in the slot library include the entity categories in the dialogue slot table;
[0124] Matching module 4 is configured to determine the second topic of the current sentence and its corresponding matching probability value in response to the number of successful matches of the dialogue slot table in the slot library;
[0125] The topic determination module 5 is configured to determine the topic of the current sentence in response to the topic corresponding to the larger one of the predicted probability value and the matching probability value being the first topic or the second topic.
[0126] Reference below Figure 4 , which shows an electronic device (eg Figure 1 A structural diagram of a computer device 400 (a server or terminal device as shown). Figure 4 The electronic device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.
[0127] like Figure 4 As shown, the computer device 400 includes a central processing unit (CPU) 401 and a graphics processing unit (GPU) 402, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 403 or the program loaded from the storage part 409 to the random access memory (RAM) 404. Various programs and data required for the operation of the device 400 are also stored in the RAM 404. The CPU 401, GPU 402, ROM 403 and RAM 404 are connected to each other via a bus 405. An input / output (I / O) interface 406 is also connected to the bus 405.
[0128] The following components are connected to the I / O interface 406: an input section 407 including a keyboard, a mouse, and the like; an output section 408 including a display such as a liquid crystal display (LCD), a speaker, and the like; a storage section 409 including a hard disk and the like; and a communication section 410 including a network interface card such as a LAN card or a modem. The communication section 410 performs communication processing via a network such as the Internet. A drive 411 may also be connected to the I / O interface 406 as needed. A removable medium 412, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, and the like, is installed in the drive 411 as needed, so that a computer program read therefrom can be installed into the storage section 409 as needed.
[0129] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication part 410, and / or installed from a removable medium 412. When the computer program is executed by the central processing unit (CPU) 401 and the graphics processing unit (GPU) 402, the above-mentioned functions defined in the method of the present application are performed.
[0130] It should be noted that the computer-readable medium described in this application may be a computer-readable signal medium or a computer-readable medium, or any combination of the two. Computer-readable media may be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor devices, apparatuses, or components, or any combination thereof. More specific examples of computer-readable media may include, but are not limited to, an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this application, a computer-readable medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution device, apparatus, or component. In this application, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution apparatus, device, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical cable, RF, or any suitable combination thereof.
[0131] Computer program code for performing the operations of the present application can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0132] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the devices, methods and computer program products according to various embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, program segment or a part of code, and the module, program segment or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based device that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0133] The modules involved in the embodiments described in this application may be implemented in software or hardware, and may also be set in a processor.
[0134] As another aspect, the present application also provides a computer-readable medium, which may be included in the electronic device described in the above embodiment; or may exist independently and not be assembled into the electronic device. The computer-readable medium carries one or more programs, and when the one or more programs are executed by the electronic device, the electronic device: obtains a topic dataset, and constructs a slot library with multiple rows of slots based on the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence; pre-processes the current sentence of the dialogue to be recognized in the dialogue system and inputs it into a trained single-sentence topic recognition model to predict the first topic of the current sentence and its corresponding predicted probability value; recognizes all entities in the current sentence and all previous sentences, and establishes a dialogue slot table based on all entities and their categories in the current sentence, wherein the entity categories in the slot library include the entity categories in the dialogue slot table; determines the second topic of the current sentence and its corresponding matching probability value in response to the number of successful matches of the dialogue slot table in the slot library; and determines the topic of the current sentence in response to the larger of the predicted probability value and the matching probability value corresponding to the first topic or the second topic.
[0135] The above description is merely a preferred embodiment of the present application and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the invention involved in this application is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned inventive concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this application.
Claims
1. A method for identifying topics in a dialogue system by combining contextual information, characterized in that: The following steps are involved: S1, obtaining a topic dataset, and constructing a slot library with multiple rows of slots according to the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence; S2, pre-processing the current sentence of the dialogue to be recognized in the dialogue system and inputting it into the trained single-sentence topic recognition model to predict the first topic of the current sentence and its corresponding prediction probability value; S3, identifying all entities in the current sentence and all previous sentences, and establishing a dialogue slot table based on all entities and their categories in the current sentence, where the entity categories in the slot library include the entity categories in the dialogue slot table; S4, in response to the number of successful matches of the dialog slot table in the slot library, determining the second topic of the current sentence and its corresponding matching probability value, specifically including: S41, determining whether the dialog slot table is empty; if so, directly using the first topic as the topic of the current sentence; otherwise, constructing entity pairs between entities of different categories in the dialog slot table, and matching the entity pairs in the dialog slot table in the slot library; S42, if one of the entity pairs in the conversation slot table is identical to an entity in one row of slots in the slot library, the match is successful, and the third topic corresponding to the entity in one row of slots in the slot library is recorded; S43, repeating step S42 to match the conversation slot table with the slot library, and obtaining the total number of successful matches of the conversation slot table in the slot library and the number of successful matches of at least one third topic and its corresponding topic; The third topic with the highest number of successful matches among the number of successful matches corresponding to at least one of the third topics is used as the second topic; Dividing the highest number of successful matches among the number of successful matches corresponding to at least one of the third topics by the total number of successful matches in the dialog slot table in the slot library to obtain the matching probability value; S5, in response to the topic corresponding to the larger one of the predicted probability value and the matching probability value being the first topic or the second topic, determining it as the topic of the current sentence.
2. The method for identifying topics in a dialogue system using contextual information according to claim 1, wherein: In step S1, a slot library with multiple rows of slots is constructed based on the relationship between the topic of each sentence in the topic dataset and the entities of each category in the sentence, specifically including: S11, identifying entities of each sentence in the subject dataset using named entity recognition; S12, obtain each row of slots in the slot library according to the topic of each sentence and the entities of each category identified; S13, repeating steps S11-S12 to obtain a slot library corresponding to multiple sentences in the topic dataset.
3. The method for identifying topics in a dialogue system using contextual information according to claim 1, wherein: The preprocessing process of each sentence in the dialogue system specifically includes: Use the Jieba word segmenter to segment each sentence and obtain at least one word in each sentence; Use Word2vec to process each word and obtain word vector embedding representation; The word vector embedding representations of each sentence are concatenated to obtain a merge matrix.
4. The method for identifying topics in a dialogue system using contextual information according to claim 3, wherein: The single-sentence topic identification model is a text classification model based on machine learning, and the single-sentence topic identification model includes at least a fully connected layer and a softmax layer.
5. The method for identifying topics in a dialogue system using contextual information according to claim 4, wherein: The training process of the single sentence topic identification model includes: Preprocess each sentence in the subject dataset to obtain a merge matrix; Using one-hot encoding to encode the topics in the topic dataset into a first vector of 1*n dimension; Input the merged matrix into the fully connected layer and the softmax layer to obtain a second vector; A cross entropy loss function between the second vector and the first vector is calculated, and parameters of the single-sentence topic identification model are optimized step by step and iteratively.
6. The method for identifying topics in a dialogue system in combination with context information according to any one of claims 1 to 5, characterized in that: Also includes: Add, delete or modify the slots in the slot library, and repeat steps S2-S5 to adjust the recognition effect of the topic of the current sentence.
7. A topic identification device for a dialogue system incorporating contextual information, characterized in that: include: A slot library construction module is configured to obtain a topic dataset and construct a slot library with multiple rows of slots according to the relationship between the topic of each sentence in the topic dataset and the entity of each category in the sentence; a topic prediction module configured to pre-process a current sentence of a dialogue to be recognized in the dialogue system and input the pre-processed sentence into a trained single-sentence topic recognition model to predict a first topic of the current sentence and its corresponding predicted probability value; a dialog slot table construction module configured to identify all entities in the current sentence and all previous sentences, and to establish a dialog slot table based on all entities and their categories in the current sentence, wherein the entity categories in the slot library include the entity categories in the dialog slot table; The matching module is configured to determine the second topic of the current sentence and its corresponding matching probability value in response to the number of successful matches of the dialogue slot table in the slot library, specifically including: A first submodule is configured to determine whether the dialog slot table is empty; if so, directly use the first topic as the topic of the current sentence; otherwise, construct entity pairs between entities of different categories in the dialog slot table, and match the entity pairs in the dialog slot table in the slot library; The second submodule is configured to: if one of the entity pairs in the conversation slot table is the same as the entity in one row of slots in the slot library, the match is successful, and record the third topic corresponding to the entity in one row of slots in the slot library; A third submodule is configured to repeatedly execute the second submodule to match the conversation slot table with the slot library, and obtain a total number of successful matches of the conversation slot table in the slot library and a number of successful matches of at least one third topic and its corresponding topic; The third topic with the highest number of successful matches among the number of successful matches corresponding to at least one of the third topics is used as the second topic; Dividing the highest number of successful matches among the number of successful matches corresponding to at least one of the third topics by the total number of successful matches in the dialog slot table in the slot library to obtain the matching probability value; The topic determination module is configured to determine the topic of the current sentence in response to the topic corresponding to the larger one of the predicted probability value and the matching probability value being the first topic or the second topic.
8. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Ancient poem semantic retrieval method based on knowledge graph
CN112101040A
Multi-round dialogue emotion recognition model training method and device, equipment and medium
CN113297366A