Dialogue text vector representation method and computer readable storage medium
Through the processing of clauses and role embedding of dialogue text, combined with the large language model, the problems that were not considered in dialogue scene information in the existing technology are solved, and the vector representation and theme classification accuracy of dialogue text are improved.
Patent Information
- Application Number
- CN202411081902.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-12-03
- Estimated Expiration
- 2044-08-08
AI Technical Summary
The existing dialogue text sentence vector representation method fails to effectively consider dialogue scene information, resulting in low accuracy in topic classification.
By obtaining the target dialogue text, processing it in sentences, and embedding sentences, roles and dialogue rounds into vectors, inputting them into a large language model, combining the mask matrix to determine the role sentence vector, enhancing the vector representation of the dialogue text, taking into account the context and Role relationship.
The vector representation smoothness and accuracy of dialogue text are improved, which can better explore information on various dimensions of dialogue topics and improve the accuracy of subsequent topic classification.
Smart Images

Figure CN119066198A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology, and in particular to a conversation text vector representation method and a computer-readable storage medium. Background Art
[0002] At present, banking services are gradually shifting from offline face-to-face services to online services, which has generated a large number of telephone transactions and online chat conversations. Call recordings can be converted into conversation text corpus through ASR, and NLP technology can be used to perform text analysis on customer needs and business personnel behaviors, and classify conversation topics. Better meet customer needs and serve customers. The technical basis for analyzing these conversation texts is to better represent the sentences of the conversation with vectors. At present, the existing conversation text sentence vector representation methods (such as comparison algorithms and BERT) do not consider the information of the conversation scene, resulting in low accuracy in subsequent topic classification. Summary of the invention
[0003] The embodiments of the present application provide a method for representing a conversation text vector and a computer-readable storage medium, which can deeply consider the information of the conversation scene to improve the accuracy of subsequent topic classification.
[0004] In a first aspect, an embodiment of the present application provides a method for representing a conversation text vector, the method comprising:
[0005] Acquire a target dialogue text, wherein the target dialogue text includes at least two characters and the target dialogue text includes at least one round of dialogue;
[0006] Processing the target dialogue text into sentences to obtain a plurality of sentences;
[0007] Inputting the plurality of sentences into a first large language model to obtain a plurality of sentence vectors;
[0008] Perform sentence embedding operations, role embedding operations, and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors, and multiple dialogue turn embedding sentence vectors;
[0009] Adding the plurality of sentence embedding vectors, the plurality of role embedding vectors, and the plurality of dialogue turn embedding vectors to obtain a first sentence vector matrix;
[0010] Inputting the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix;
[0011] Obtaining a mask matrix for each of the at least two roles to obtain at least one mask matrix;
[0012] Determine a sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix;
[0013] A sentence vector representation of a target dialogue text is determined according to the sentence vector matrix of the at least one role.
[0014] In a second aspect, an embodiment of the present application provides a device for representing a conversation text vector, the device comprising: an acquisition unit, a sentence unit, an input unit, an embedding unit, and a determination unit, wherein:
[0015] The acquisition unit is used to acquire a target dialogue text, wherein the target dialogue text includes at least two characters and the target dialogue text includes at least one round of dialogue;
[0016] The sentence division unit is used to process the target dialogue text into sentences to obtain a plurality of sentences;
[0017] The input unit is used to input the plurality of sentences into the first large language model to obtain a plurality of sentence vectors;
[0018] The embedding unit is used to perform sentence embedding operations, role embedding operations and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors; add the multiple sentence embedding sentence vectors, the multiple role embedding sentence vectors and the multiple dialogue turn embedding sentence vectors to obtain a first sentence vector matrix;
[0019] The input unit is further used to input the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix;
[0020] The acquisition unit is further used to acquire a mask matrix of each of the at least two roles to obtain at least one mask matrix;
[0021] The determination unit is used to determine the sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix; and determine the sentence vector representation of the target dialogue text according to the sentence vector matrix of the at least one role.
[0022] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps in the first aspect of the embodiment of the present application.
[0023] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in the first aspect of the embodiment of the present application.
[0024] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in the first aspect of the embodiment of the present application. The computer program product may be a software installation package.
[0025] The implementation of the embodiments of the present application has the following beneficial effects:
[0026] The dialogue text vector representation method and computer-readable storage medium described in the present application obtain a target dialogue text, the target dialogue text includes at least two roles, the target dialogue text includes at least one round of dialogue, the target dialogue text is processed into sentences to obtain multiple sentences, the multiple sentences are input into a first large language model to obtain multiple sentence vectors, the multiple sentence vectors are subjected to sentence embedding operations, role embedding operations and dialogue turn embedding operations to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors, the multiple sentence embedding sentence vectors, the multiple role embedding sentence vectors and the multiple dialogue turn embedding sentence vectors are added together to obtain a first sentence vector matrix, the first sentence vector matrix is input into a second large language model to obtain a second sentence vector matrix, a mask matrix of each of the at least two roles is obtained to obtain at least one mask matrix, and a mask matrix is generated according to the second sentence vector matrix. The vector matrix and at least one mask matrix determine the sentence vector matrix of at least one character, and the sentence vector representation of the target dialogue text is determined according to the sentence vector matrix of at least one character. In this way, considering the context can enhance the connection between dialogues of different characters and guide the sub-layers between dialogue rounds, so that each round of dialogue can be smoothly connected in series, and the vector representation is also smoother. The characters represent identities, and different identities have different corresponding social statuses. The feelings and status between the characters are deeply mined, and the switching of sub-topics of different dialogues in different rounds corresponds to the switching of various dimensions related to the dialogue topic, that is, the information of each dimension related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the characters, and the differences between different statuses and identities, making the vector representation more down-to-earth, which helps to improve the accuracy of subsequent topic classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1A It is a flowchart of a method for representing a conversation text vector provided in an embodiment of the present application;
[0029] Figure 1B It is another flowchart of a method for representing a conversation text vector provided in an embodiment of the present application;
[0030] Figure 2 It is a flowchart of another method for representing a conversation text vector provided in an embodiment of the present application;
[0031] Figure 3 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application;
[0032] Figure 4 It is a block diagram of the functional units of a conversation text vector representation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0034] The terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.
[0035] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0036] The following is an introduction to the relevant terms involved in this application.
[0037] The electronic devices described in the embodiments of the present application may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, driving recorders, servers, laptops, mobile Internet devices (Mobile Internet Devices, MID) or wearable devices (such as smart watches, Bluetooth headsets), etc. The above are only examples and not exhaustive, including but not limited to the above electronic devices. The server can be an outsourced server, cloud server, edge server, etc., which is not limited here.
[0038] Natural Language Processing (NLP): enables computers to understand, generate and process natural languages, such as English, Chinese and other languages used by humans in daily life, including tasks such as sentiment analysis, machine translation, named entity recognition, speech recognition, question-answering systems, etc.
[0039] Transformer: A deep learning model based on the self-attention mechanism. It is widely used in many other tasks of natural language processing, such as text classification, sentiment analysis, question-answering systems, etc.
[0040] Word embedding: It is a technology that maps discrete data (such as vocabulary, categories, etc.) to continuous vectors. In the field of natural language processing (NLP), word embedding is often used to convert words or phrases into fixed-length vector representations so that computers can better understand and process natural language data.
[0041] Contrastive Learning: is an unsupervised learning method that aims to learn useful feature representations from a large amount of unlabeled data. The core idea is to automatically construct similar and dissimilar instances and train a model so that similar instances are close in the feature space, while dissimilar instances are far away. This method encourages the model to learn high-level features that can distinguish different categories of data.
[0042] Automatic Speech Recognition (ASR): A technology that converts human speech signals into computer-readable text. It is an important branch of artificial intelligence and natural language processing, and is widely used in scenarios such as smart assistants, voice search, customer service automation, and barrier-free technology.
[0043] BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language model based on Transformer. In BERT, `[CLS]` and `[SEP]` are special tokens used to indicate the beginning and end of a sentence, or to separate when processing multiple sentences.
[0044] In related technologies, with the rapid development of deep learning technology, natural language processing (NLP) technology based on deep learning has shown great advantages in dialogue systems, information retrieval, text mining, and sentiment analysis compared with traditional rules, grammar analysis and other methods. Text vectorization is the basis of NLP algorithms. The vector representation method aims to capture and represent semantic information by mapping text into a continuous, low-dimensional vector space. After obtaining the vector representation of the text, it can be input into downstream models such as similarity calculation and text classification to complete tasks such as information retrieval and sentiment recognition.
[0045] In the specific implementation, let's take an example. Suppose there is the following dialogue case D:
[0046] Customer Service: Hello, XX Bank Customer Service is here to serve you.
[0047] Customer: What gifts can I redeem with my points? I want to know.
[0048] Customer Service: Points can be exchanged for various gifts, such as travel packages, movie tickets, etc. You can log in to online banking to view the exchange list and choose the gift that suits you.
[0049] Customer: Travel packages? Sounds good, I have to check it out!
[0050] In the related art, a contrast algorithm (Dial2vec) can be used to represent the above conversation as a conversation text vector. Dial2vec has achieved good results in clustering, conversation retrieval, and conversation semantic similarity sorting on many verification data sets. However, since this method treats the entire conversation as a sample input and the model time complexity is O(nd^2), Dial2vec limits the length to 512. However, in actual bank customer service scenarios, there are many conversations that exceed 512 in length, especially in bank telemarketing, debt collection and other scenarios, where the conversation text length is often longer than 512. Therefore, this limitation leads to the need to truncate the text conversations in many scenarios of Dial2vec. In addition, training a large amount of text with a length of 512 takes a long time and requires high hardware resources.
[0051] In order to solve the defects in the related art, the embodiment of the present application provides a method for representing a conversation text vector, which may include the following steps:
[0052] Acquire a target dialogue text, wherein the target dialogue text includes at least two characters and the target dialogue text includes at least one round of dialogue;
[0053] Processing the target dialogue text into sentences to obtain a plurality of sentences;
[0054] Inputting the plurality of sentences into a first large language model to obtain a plurality of sentence vectors;
[0055] Perform sentence embedding operations, role embedding operations, and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors, and multiple dialogue turn embedding sentence vectors;
[0056] Adding the plurality of sentence embedding vectors, the plurality of role embedding vectors, and the plurality of dialogue turn embedding vectors to obtain a first sentence vector matrix;
[0057] Inputting the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix;
[0058] Obtaining a mask matrix for each of the at least two roles to obtain at least one mask matrix;
[0059] Determine a sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix;
[0060] A sentence vector representation of a target dialogue text is determined according to the sentence vector matrix of the at least one role.
[0061] In an embodiment of the present application, a target dialogue text is obtained, the target dialogue text includes at least two roles, the target dialogue text includes at least one round of dialogue, the target dialogue text is sentence-processed to obtain a plurality of sentences, the plurality of sentences are input into a first large language model to obtain a plurality of sentence vectors, sentence embedding operations, role embedding operations and dialogue turn embedding operations are performed on the plurality of sentence vectors to obtain a plurality of sentence embedding sentence vectors, a plurality of role embedding sentence vectors and a plurality of dialogue turn embedding sentence vectors, the plurality of sentence embedding sentence vectors, the plurality of role embedding sentence vectors and the plurality of dialogue turn embedding sentence vectors are added to obtain a first sentence vector matrix, the first sentence vector matrix is input into a second large language model to obtain a second sentence vector matrix, a mask matrix of each of the at least two roles is obtained to obtain at least one mask matrix, a sentence vector matrix of at least one role is determined according to the second sentence vector matrix and the at least one mask matrix, and a sentence vector matrix of at least one role is determined according to the sentence vector matrix of at least one role. The target dialogue text sentence vector representation is determined by the matrix. In this way, considering the context can enhance the connection between different role dialogues and guide the sub-layering between dialogue rounds, so that each round of dialogue can be smoothly connected in series, and the vector representation is also smoother. The role represents the identity, and different identities have different corresponding social status. The feelings and status between the roles are deeply mined, and the sub-topics of different dialogues in different rounds are switched, that is, the various dimensional information related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the role, the difference between different status and identity, making the vector representation more down-to-earth, which is helpful to improve the accuracy of subsequent topic classification. At the same time, the comparison algorithm (Dial2vec) in the article is solved, and the input length problem and resource problem (computing resources) of the entire dialogue are directly word-token encoded.
[0062] The embodiments of the present application are described in detail below.
[0063] See also Figure 1A , Figure 1A : is a flow chart of a method for representing a conversation text vector provided by an embodiment of the present application. As shown in the figure, the method for representing a conversation text vector includes:
[0064] 101. Obtain a target dialogue text, where the target dialogue text includes at least two characters and the target dialogue text includes at least one round of dialogue.
[0065] In the embodiment of the present application, the target conversation text may be a conversation text converted from a call recording. Specifically, a call recording may be obtained, and the call recording may be converted into a conversation text to obtain the target conversation text.
[0066] The target dialogue text may include at least two characters, and the target dialogue text may include at least one round of dialogue.
[0067] 102. Process the target dialogue text into sentences to obtain a plurality of sentences.
[0068] In the embodiment of the present application, the target dialogue text may be processed by sentence division, that is, a dialogue is divided into multiple sentences to obtain multiple sentences.
[0069] 103. Input the multiple sentences into a first large language model to obtain multiple sentence vectors.
[0070] In the embodiment of the present application, the first language model can be preset or the system defaults. The first language model can include at least one of the following: a generative pre-trained model (GPT), a BERT model, a t5 model, a roberta model, etc., which are not limited here.
[0071] In a specific implementation, multiple sentences may be input in parallel into the first language model. Specifically, after the sentences are input in parallel, multiple sentence vectors are obtained. In this way, the sentence vectors in the conversation may be represented and learned from the word-token level.
[0072] 104. Perform sentence embedding operations, role embedding operations, and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors, and multiple dialogue turn embedding sentence vectors.
[0073] In the embodiment of the present application, a plurality of sentence vectors may be subjected to sentence embedding operations, role embedding operations, and dialogue turn embedding operations to obtain a plurality of sentence embedding sentence vectors, a plurality of role embedding sentence vectors, and a plurality of dialogue turn embedding sentence vectors. The context may be considered to enhance the relationship between dialogues of different roles, the feelings and status between the roles may be deeply mined through the plurality of role embedding sentence vectors, and the sub-layers between the dialogue turns may be guided through the plurality of dialogue turn embedding sentence vectors, so that each round of dialogue may be smoothly connected in series, that is, the context may be considered to enhance the relationship between dialogues of different roles, and the sub-layers between the dialogue turns may be guided, so that each round of dialogue may be smoothly connected in series, and the vector representation may be smoother, the roles may represent identities, and different identities may have different corresponding social statuses, and the feelings and status between the roles may be deeply mined, and the switching of sub-topics of different dialogues in different turns may be corresponding, that is, the information of each dimension related to the dialogue topic may be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the roles, and the differences between different statuses and identities, so that the vector representation is more down-to-earth, which helps to improve the accuracy of subsequent topic classification.
[0074] 105. Add the multiple sentence embedding sentence vectors, the multiple role embedding sentence vectors, and the multiple dialogue turn embedding sentence vectors to obtain a first sentence vector matrix.
[0075] In the embodiment of the present application, multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue round embedding sentence vectors can be added to obtain the first sentence vector matrix. In this way, considering the context can enhance the connection between different role dialogues, and guide the sub-layer between dialogue rounds, so that each round of dialogue can be smoothly connected in series, and the vector representation is also smoother. The role represents the identity, and the corresponding social status is different for different identities. The feelings and status between the roles are deeply mined, and the switching of sub-topics corresponding to different dialogues in different rounds, that is, the information of each dimension related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the role, the difference between different status and identity, so that the vector representation is more down-to-earth, which helps to improve the accuracy of subsequent topic classification. To give a simple example, the same sentence is spoken in different backgrounds, the meaning is different, or the meaning expressed by different speakers is different.
[0076] 106. Input the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix.
[0077] The second largest language model may be preset or system default, and the first largest language model may be the same as or different from the second largest language model. The second largest language model may include at least one of the following: a generative pre-trained model (GPT), a BERT model, a t5 model, a roberta model, etc., which are not limited here.
[0078] In a specific implementation, the first sentence vector matrix can be input into the second largest language model to obtain the second sentence vector matrix. In this way, the sentence vector representation learning in the conversation can be performed from the sentence-token level.
[0079] The second largest language model may be the same as or different from the first largest language model.
[0080] 107. Obtain a mask matrix of each of the at least two roles to obtain at least one mask matrix.
[0081] In an embodiment of the present application, a mask matrix of each of at least two roles can be obtained to obtain at least one mask matrix. That is, in order to obtain sentence vector matrices corresponding to different roles, a mask matrix of each of at least two roles can be obtained to obtain at least one mask matrix. The sentence vector matrices corresponding to different roles are obtained through the mask matrices.
[0082] 108. Determine a sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix.
[0083] In the specific implementation, each role corresponds to a mask matrix, and each role mask matrix is used to extract the chat content and related features corresponding to the role. The sentence vector matrix of at least one role can be determined based on the second sentence vector matrix and at least one mask matrix. In this way, the conversation content of each role can be obtained based on the conversation order to generate its corresponding sentence vector matrix.
[0084] 109. Determine a sentence vector representation of the target dialogue text according to the sentence vector matrix of the at least one role.
[0085] In a specific implementation, the sentence vector representation of the target dialogue text can be determined based on the sentence vector matrix of at least one character. In this way, the sentence vector representation of the dialogue text of each character can be obtained. Of course, the sentence vector representation of the dialogue text of multiple characters can also be obtained.
[0086] In some possible examples, the above step 109, determining the sentence vector representation of the target dialogue text according to the sentence vector matrix of the at least one role, may include the following steps:
[0087] 91. Determine a self-interaction sentence vector matrix and a role-interaction sentence vector matrix of each role according to the sentence vector matrix of the at least one role;
[0088] 92. Determine a first sentence vector representation of each of the at least one role according to the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role and the sentence vector matrix of the at least one role;
[0089] 93. Determine a second sentence vector representation of each of the at least one role according to the first sentence vector representation of each of the at least one role and the first sentence vector matrix;
[0090] 94. Determine the target dialogue text sentence vector representation based on the second sentence vector representation of each role in the at least one role.
[0091] Among them, the self-interaction sentence vector matrix of each role can be understood as the result of the interaction between the sentence vector matrix of the role and the sentence vector matrix of the role, and the role interaction sentence vector matrix can be understood as the result of the interaction between the sentence vector matrix of the role and the sentence vector matrices of other roles.
[0092] In a specific implementation, the self-interaction sentence vector matrix and the role interaction sentence vector matrix of each role can be determined based on the sentence vector matrix of at least one role. The identity and status of the role can be repeatedly explored through the self-interaction sentence vector matrix, and the role attributes of the role can be enhanced by deducing the emotional changes between similar roles. Correspondingly, the role interaction sentence vector matrix can include the attitude of the role towards other roles, showing the differences between identities, as well as other humble attributes, and deeply explore the identity and status attributes of the role. Moreover, by deducing the emotional changes between different roles, the role vector representation is made more down-to-earth.
[0093] Furthermore, the first sentence vector representation of each of at least one character can be determined based on the self-interaction sentence vector matrix and the character interaction sentence vector matrix of each character and the sentence vector matrix of at least one character; the second sentence vector representation of each of at least one character can be determined based on the first sentence vector representation of each of at least one character and the first sentence vector matrix; and the sentence vector representation of the target dialogue text can be determined based on the second sentence vector representation of each of at least one character.
[0094] Further, in some possible examples, the above step 91, determining the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role according to the sentence vector matrix of the at least one role, may include the following steps:
[0095] 911. Obtain a first transposed matrix of a sentence vector matrix of a first role, where the first role is any role among the at least one role;
[0096] 912. Determine a self-interaction sentence vector matrix of the first role according to the sentence vector matrix of the first role and the first transposed matrix;
[0097] 913. Determine a second transposed matrix of a sentence vector matrix of a second role, where the second role is any role among the at least one role except the first role;
[0098] 914. Determine a role interaction sentence vector matrix of the first role according to the sentence vector matrix of the first role and the second transposed matrix.
[0099] In a specific implementation, taking the first character as an example, the first character is any one of at least one character, and the first transposed matrix of the sentence vector matrix of the first character can be obtained, and the self-interaction sentence vector matrix of the first character can be determined according to the sentence vector matrix of the first character and the first transposed matrix. The identity and status of this character can be repeatedly explored through the self-interaction sentence vector matrix, and the role attributes of this character can be enhanced by deducing the emotional changes between similar characters.
[0100] Furthermore, taking the second role as an example, the second role is any role among at least one role except the first role. The second transposed matrix of the sentence vector matrix of the second role can be determined, and then the role interaction sentence vector matrix of the first role can be determined based on the sentence vector matrix of the first role and the second transposed matrix. In this way, the role interaction sentence vector matrix can include the attitude of this role towards other roles, showing the differences between identities, as well as other humble attributes, deeply explore the identity and status attributes of the role, and by deducing the emotional changes between different roles, make the role vector representation more down-to-earth.
[0101] For example, the target dialogue text includes two characters, character r1 and character r2. In order to obtain the interaction information, in the specific implementation, a dot product operation is performed between the sentence-levels, that is, the self-interaction matrix C can be obtained. r1 , and the role-interaction matrix C r1′ , and the interaction matrix is calculated for each interlocutor.
[0102] In the specific implementation, the interaction matrix can be obtained for the role r1:
[0103] C r1 =H r1 (H r1 ) T
[0104] C r1′ =H r1 (H r2 ) T
[0105] Among them, C r1 ∈R r1*r1 , C r1′ =R r1*r2 , C r1 Represents the self-interaction sentence vector matrix of role r1, H r1 Represents the sentence vector matrix of role r1, (H r1 ) T represents the transpose of the sentence embedding matrix of role r1, C r1′ Represents the role interaction sentence vector matrix of role r1, (H r2 ) T Represents the transpose of the sentence embedding matrix for role r2.
[0106] Correspondingly, for role r2, the interaction matrix can be obtained as follows
[0107] C r2 =H r2 (Hr2 ) T
[0108] C r2′ =H r2 (H r1 ) T
[0109] Among them, C r2 ∈R r2*r2 , C r2′ =R r2*r1 , C r2 Represents the self-interaction sentence vector matrix of role r2, H r2 Represents the sentence vector matrix of role r2, (H r2 ) T represents the transpose of the sentence embedding matrix of role r2, C r2′ Represents the role interaction sentence vector matrix of role r2, (H r1 ) T Represents the transpose of the sentence embedding matrix for role r1.
[0110] Further, in some possible examples, the above step 92, determining the first sentence vector representation of each role of the at least one role according to the self-interaction sentence vector matrix and the role interaction sentence vector matrix of each role and the sentence vector matrix of the at least one role, may include the following steps:
[0111] 921. Determine a self-interaction sentence vector representation of the second role according to the self-interaction sentence vector matrix of the second role and the sentence vector matrix of the second role;
[0112] 922. Determine a role sentence vector representation of the second role according to the role interaction sentence vector matrix of the second role and the sentence vector matrix of a third role; the third role is any role among the at least one role except the second role;
[0113] 923. Determine a first sentence vector representation of the second role according to the self-interaction sentence vector representation and the role sentence vector representation.
[0114] In an embodiment of the present application, taking the second role as an example, the second role is any role of at least one role, and the self-interaction sentence vector representation of the second role can be determined according to the self-interaction sentence vector matrix of the second role and the sentence vector matrix of the second role. Furthermore, the third role is any role of at least one role except the second role, and the role sentence vector representation of the second role is determined according to the role interaction sentence vector matrix of the second role and the sentence vector matrix of the third role. The first sentence vector representation of the second role is determined according to the self-interaction sentence vector representation and the role sentence vector representation. In a specific implementation, the first sentence vector representation of the second role may include the self-interaction sentence vector representation and the role sentence vector representation of the second role. Self-interaction can repeatedly explore the identity and status of this role, and enhance the role attributes of this role by deducing emotional changes between similar roles. The interaction between corresponding roles can include the attitude of this role towards other roles, showing the differences between identities, as well as other humble attributes, deeply explore the identity and status attributes of the role, and make the role vector representation more down-to-earth by deducing emotional changes between different roles.
[0115] In a specific implementation, when the target dialogue text includes two characters, the third character may be the first character; when the target dialogue text includes three or more characters, the third character may be any character except the first character and the second character.
[0116] For example, the target dialogue text includes two characters, namely character r1 and character r2, and then the two characters respectively obtain two different sentence vector representations.
[0117] In the specific implementation, for role r1:
[0118] E r1 =C r1 H r1
[0119] E r1′ =C r1′ H r2
[0120] Among them, E r1 ∈R r1*n , E r1 ′∈R r1*n , where C r1 Represents the self-interaction sentence vector matrix of role r1, H r1 Represents the sentence vector matrix of role r1, E r1 Represents the self-interaction sentence vector representation of role r1, H r2 Represents the sentence vector matrix of role r2, E r1′ Represents the role sentence vector representation of role r1.
[0121] Furthermore, for role r2:
[0122] E r2 =C r2 H r2
[0123] E r2′ =C r2′ H r1
[0124] Among them, E r2 ∈R r2*n , E r2 ′∈R r2*n , where C r2 Represents the self-interaction sentence vector matrix of role r2, H r2 Represents the sentence vector matrix of role r2, E r2 Represents the self-interaction sentence vector representation of role r2, H r1 Represents the sentence vector matrix of role r1, E r2′ Represents the role sentence vector representation of role r2.
[0125] Furthermore, for each character, we can obtain the vector E that combines the self-interaction information: r1 , E r2 , and the representation vector E that combines the interaction information between different roles r1′ , E r2′ .
[0126] Further, in some possible examples, the above step 93, determining the second sentence vector representation of each role in the at least one role according to the first sentence vector representation of each role of the at least one role and the first sentence vector matrix, may include the following steps:
[0127] 931. Perform a weighted operation on the self-interaction sentence vector representation and the role sentence vector representation to obtain an intermediate sentence vector representation;
[0128] 932. Perform vector concatenation on the first sentence vector matrix and the intermediate sentence vector representation to obtain a second sentence vector representation of the second role.
[0129] In the embodiment of the present application, the corresponding weights of the self-interaction sentence vector representation and the role sentence vector representation can be obtained to obtain multiple weights, the sum of the multiple weights is 1, and then the multiple weights and the self-interaction sentence vector representation and the role sentence vector representation are used to perform weighted operations to obtain an intermediate sentence vector representation. Next, the first sentence vector matrix and the intermediate sentence vector representation are vector spliced to obtain a second sentence vector representation of the second role. Self-interaction can repeatedly explore the identity and status of this role, and enhance the role attributes of this role by deducing the emotional changes between similar roles. The interaction between corresponding roles can include the attitude of this role towards other roles, showing the differences between identities, as well as other humble attributes, deeply explore the identity and status attributes of the role, and make the role vector representation more down-to-earth by deducing the emotional changes between different roles.
[0130] For example, the target dialogue text includes two characters, namely, character r1 and character r2. Taking character r1 as an example, the details are as follows:
[0131] f i r1 =H i ||E i
[0132]
[0133] Among them, || represents vector concatenation, θ is a parameter used to control the ratio of self-interaction and interaction between roles in the final dialogue text sentence vector information, and f i r1 ∈R 1*2d , i∈[1,r1]. By controlling the parameter θ, E i That is, the semantic information of self-interaction and interaction between roles can be combined at the same time, or the two types of information can be used separately, such as E i =E r1 '(θ=0), or E i =E r1 (θ=1) r1 Represents the self-interaction sentence vector representation of role r1, E r1′ The role sentence vector representation of role r1, E i The intermediate sentence vector representation of role r1, H i It can represent the word-token level sentence vector representation of role r1.
[0134] Similarly, taking role r2 as an example, the details are as follows:
[0135] f i r2 =H i ||Ei
[0136]
[0137] Among them, || represents vector concatenation, θ is a parameter used to control the ratio of self-interaction and interaction between roles in the final dialogue text sentence vector information, and f i r2 ∈R 2*2d , i∈[[1,r2]. By controlling the parameters θ, E i That is, the semantic information of self-interaction and interaction between roles can be combined at the same time, or the two types of information can be used separately, such as E i =E r1′ (θ=0), or E i =E r1 (θ=1) r1 Represents the self-interaction sentence vector representation of role r1, E r2 Represents the self-interaction sentence vector representation of role r2, E r2′ represents the role sentence vector representation of role r2, H i It can represent the word-token level sentence vector representation of role r2.
[0138] In this example, we learn the representation of sentence vectors in the conversation from both the word-token level and the sentence-token level, and then concatenate the two vectors. This not only retains the basic semantic information from a large amount of public text corpus, but also learns the semantic information in the conversation-specific scenarios such as the context, turns, and interaction between dialogue roles. Compared with the comparison algorithm (Dial2vec), directly encoding the entire conversation into word-tokens has input length issues and resource issues (computing resources).
[0139] In some possible examples, the above step 108, determining the sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix, may include the following steps:
[0140] 81. Determine a third transposed matrix of a first mask matrix corresponding to a first role; the first mask matrix is any mask matrix in the at least one mask matrix; the first role is one of the at least one role;
[0141] 82. Perform a dot product operation on the second sentence vector matrix and the third transposed matrix to obtain a sentence vector matrix for the first role.
[0142] In an embodiment of the present application, a third transposed matrix of a first mask matrix corresponding to a first role is determined, where the first mask matrix is any mask matrix in at least one mask matrix, and the first role is one of at least one role. Next, a dot product operation is performed based on the second sentence vector matrix and the third transposed matrix to obtain a sentence vector matrix of the first role. In this way, the dialogue content of each role can be obtained based on the dialogue order to generate its corresponding sentence vector matrix.
[0143] For example, take the target dialogue text including two roles as an example. In order to obtain the sentence vector matrix corresponding to different roles, a mask matrix m is generated for each of the two interlocutors. r1 and m r2 , Indicates m r1 The i-th element in , when it comes from the input token of r1, its value is 1, otherwise its value is 0. The sentence vector matrix of different roles can be obtained by calculating the following formula, as follows:
[0144] H r1 =H c ⊙(m r1 ) T
[0145] H r2 =H e ⊙(m r2 ) T
[0146] Among them, ⊙ represents the multiplication of the corresponding elements of the matrix. If there are two dialogue characters r1 speaks r1, and character r2 speaks r2 sentences, the sentence vectors H of the corresponding characters are obtained respectively. r1 ∈R r1*d , H r2 ∈R r2*d .H r1 Represents the sentence vector matrix of role r1, H r2 Represents the sentence vector matrix of role r2, m r1 Represents the mask matrix of role r1, (m r1 ) T represents the transpose of the mask matrix of role r1, m r2 Represents the mask matrix of role r2, (m r2 ) T represents the transpose of the mask matrix of role r2, H e ∈R k*d The initialization vector (i.e., H) corresponding to the sentence-token level semantic learning of all sentences in the dialogue e Corresponding to the second sentence vector matrix above).
[0147] In some possible examples, the following steps may also be included:
[0148] A1. Taking the target dialogue text as a positive sample;
[0149] A2. Randomly sample and replace sentences in the target dialogue text to obtain negative samples;
[0150] A3. Training the first large language model and / or the second large language model according to the positive samples, the negative samples and a preset loss function.
[0151] In the embodiment of the present application, the preset loss function can be pre-set or system default.
[0152] In a specific implementation, the target dialogue text can be used as a positive sample, and sentences in the target dialogue text can be randomly sampled and replaced to obtain negative samples. Then, the first language model can be trained based on the positive samples, negative samples and a preset loss function. In this way, the generalization ability of the first language model can be enhanced.
[0153] Of course, in a specific implementation, the target conversation text can be used as a positive sample, and sentences in the target conversation text can be randomly sampled and replaced to obtain negative samples. Then, the second largest language model can be trained based on the positive samples, negative samples and a preset loss function. In this way, the generalization ability of the second largest language model can be enhanced.
[0154] In some possible examples, the following steps may also be included:
[0155] B1, obtaining the audio file of the target dialogue text;
[0156] B2, sampling the audio file to obtain corpus content;
[0157] B3. Sample dialogue sentences and dialogue scene expansion prompt words according to the corpus content, input the dialogue sentences and the dialogue scene expansion prompt words into the first language model, expand the dialogue corpus as training samples, and enhance the generalization ability of the first language model.
[0158] In an embodiment of the present application, an audio file of the target dialogue text can be obtained, that is, the audio file not only contains text information but also includes corresponding sound information, and the audio file is sampled to obtain corpus content, which may also include the user's voice characteristics, and then dialogue sentences and dialogue scene expansion prompt words are sampled according to the corpus content, and the dialogue sentences and dialogue scene expansion prompt words are input into the first language model to expand the dialogue corpus. Such dialogue corpus not only deeply conforms to the user identity, but also deeply conforms to the actual context. The dialogue corpus is used as a training sample to enhance the generalization ability of the first language model.
[0159] In the specific implementation, taking the generative language model as the first language model as an example, the audio file of the target dialogue text can be obtained, and then the audio file can be sampled to obtain the corpus content, and then the dialogue sentences and dialogue scene expansion prompt words are sampled according to the corpus content, and input into the generative language model together to expand the dialogue corpus as a training sample to enhance the generalization ability of the model, that is, using the generative language model to generate dialogue corpus to enhance the dialogue data, which is conducive to improving the generalization ability of the dialogue sentence vector.
[0160] Of course, taking the second largest language model as the generative language model as an example, you can also obtain the audio file of the target dialogue text, then sample the audio file to get the corpus content, and then sample the dialogue sentences and dialogue scene expansion prompt words according to the corpus content, and input them into the generative language model together to expand the dialogue corpus as a training sample to enhance the generalization ability of the model, that is, use the generative language model to generate dialogue corpus to enhance the dialogue data, which is conducive to improving the generalization ability of the dialogue sentence vector.
[0161] In some possible examples, the following steps may also be included:
[0162] The target conversation text sentence vector representation is input into a preset topic model to obtain a target topic classification label.
[0163] In an embodiment of the present application, the preset topic model may be pre-set or system default. For example, the preset topic model may include at least one of the following: a large language model, a neural network model, etc., which are not limited here.
[0164] In the specific implementation, since the target dialogue text sentence vector reflects the corresponding characteristics of the topic to a certain extent, the target dialogue text sentence vector representation can be input into the preset topic model to obtain the target topic classification label, and the entire dialogue can be represented by a vector. A variety of dialogue vector representation methods are provided for dialogue topic classification, which solves the problem of conversation topic classification in practical applications. In this way, topic classification can be achieved quickly and accurately.
[0165] To illustrate, in the embodiment of the present application, let the symbol D represent a dialogue, part of D comes from the ASR translated dialogue recording (ASR dialogue), and the other part is generated by sampling the corpus in the ASR dialogue and using a generative large language model such as GPT to generate part of the corpus in order to expand the dialogue training corpus (GPT dialogue) and increase the generalization ability of the model.
[0166] Where D = {S1, S2, ..., S k}, where S represents a sentence and k represents the number of sentences in the dialogue D. Let symbol S = {u1,u2,...,u n} represents a sentence, u represents a character or word, the sentence S contains n characters or n words, and M represents the basic pre-trained large language model used, such as BERT, t5, roberta, etc. By inputting the relevant information of the word level (word-token level) and sentence level (sentence-token level) of the dialogue scene into the pre-trained basic large model, the basic vectors of the word-token level and sentence-token level can be obtained.
[0167] Compared with Dial2vec, which inputs the entire conversation as a sample into model M, the length of the entire conversation is limited to 512 words. All sentences in the conversation are input in parallel, after obtaining the vector of each sentence. Then the sentence vectors obtained from the conversation, such as the conversation context relationship and role interaction information, are used for training. If the length of each sentence is limited to 128 and the number of conversation rounds is limited to 128, then the text of the conversation length of 128*128=16384 words can be trained, solving the Dial2vec conversation length 512 length conversation problem. At the same time, since the time complexity of model M is O(nd^2) (0 represents complexity, n sentence length, d represents the length of the hidden layer). The input length in the embodiment of the present application is only 1 / 4 of that of Dial2vec, so the time complexity is only 1 / 4 of that of Dial2vec, reducing the training time complexity. Furthermore, in terms of capturing the semantic interaction mode between speakers in the conversation, the semantic interaction of the speaker's own context, and the semantic interaction between the speaking roles, the semantic learning of the conversation text is more sufficient.
[0168] Among them, M is a pre-trained basic model used by the algorithm. The pre-trained model is trained based on a large corpus and can be used for ordinary text vector conversations. In the dialogue scenario, the role of the basic pre-trained model is to obtain the initial sentence vector, and then learn to improve the vectorization according to the dialogue scenario.
[0169] Furthermore, let h = M(S), h∈R n*d , where h is the hidden layer output of model M, d is the hidden layer length of model M, and n is the sentence length. BERT can be used as the basic model for introduction below.
[0170] After inputting sentences in parallel, we can get each sentence in, is the vector of a word in the sentence, The vector of the special character cls is often used directly as a sentence vector, but the effect is not good.
[0171] Let H 1 ∈R n*dThe sentence vector matrix representing the algorithm for the first sentence in the conversation is obtained. 1 , you can use text-CNN for convolution pooling, or directly take avg to get the vector of each sentence The vectors corresponding to all sentences in the conversation are H∈R k*d , as the sentence vector learned at the word-token level.
[0172] After obtaining the vector of each sentence in the conversation, it is used as the input of the sentence-level model embedding. For role embedding, r i ∈R 1*d , i∈[1,k], turn embedding, t i ∈R 1 *d , i∈[1, k]. Compared with Dial2vec, sentence position embedding is no longer performed, because the word position encoding has been input in word-token. For sentence-token, tum embedding already reflects the position information of the sentence in the conversation. Therefore, when learning the context information of sentences in the conversation, the input embedding is sentence embedding, turn embedding, and role. After adding these three types of embeddings, the sentence vector that integrates the conversation role and turn information is h i +r i +t i ,h i +r i +t i ∈R 1*d , similarly, input model (the second largest language model), for all sentences we can get In order to obtain the sentence vector matrix corresponding to different roles, a mask matrix m is generated for each of the two interlocutors. r1 and m r2 , Indicates m r1 The ith element in , when the input token comes from r1, its value is 1, otherwise its value is 0.
[0173] That is, the sentence vector matrix of different roles can be obtained by calculating the following formula.
[0174] H r1 =He ⊙(m r1 ) T
[0175] H r2 =H e ⊙(m r2 ) T
[0176] Among them, ⊙ represents the multiplication of the corresponding elements of the matrix. If there are two dialogue characters r1 speaks r1, and character r2 speaks r2 sentences, the sentence vectors H of the corresponding characters are obtained respectively. r1 ∈R r1*d , H r2 ∈R r2*d .H r1 Represents the sentence vector matrix of role r1, H r2 Represents the sentence vector matrix of role r2, m r1 Represents the mask matrix of role r1, (m r1 ) T represents the transpose of the mask matrix of role r1, m r2 Represents the mask matrix of role r2, (m r2 ) T represents the transpose of the mask matrix of role r2, H e ∈R k*d The initialization vector (H) corresponding to the sentence-token level semantic learning of all sentences in the dialogue e Corresponding to the second sentence vector matrix above).
[0177] For role r1, the interaction matrix can be obtained:
[0178] C r1 =H r1 (H r1 ) T
[0179] C r1′ =H r1 (H r2 ) T
[0180] Among them, C r1 ∈R r1*r1 , C r1′ =R r 1 *r2 .
[0181] Similarly, for role r2, the interaction matrix can be obtained:
[0182] C r2 =H r2 (H r2 )T
[0183] C r2′ =H r2 (H r1 ) T
[0184] Among them, C r2 ∈R r2*r2 , C r2′ =R r2*r1 .
[0185] Then, the two roles get two different sentence vector representations:
[0186] E r1 =C r1 H r1
[0187] E r1′ =C r1′ H r2
[0188] Among them, E r1 ∈R r1*n , E r1′ ∈R r1*n .
[0189] For role r2:
[0190] E r2 =C r2 H r2
[0191] E r2′ =C r2′ H r1
[0192] Among them, E r2 ∈R r2*n , E r2′ ∈R r2*n .
[0193] For each character, we obtain the vector E that combines the self-interaction information r1 , E r2 . And the representation vector E that combines the interaction information between different roles r1′ , E r2′ .
[0194] Fusion from word-token level semantics to get word-token level sentence vector H∈R k*n , the final sentence vector expression can be expressed as:
[0195] f i r1 =H t ||E i
[0196]
[0197] Among them, || represents vector concatenation, θ is a parameter used to control the ratio of self-interaction and interaction between roles in the final dialogue text sentence vector information, and f i r1 ∈R 1*2d , i∈[1,r1]. By controlling the parameters θ, E i That is, the semantic information of self-interaction and interaction between roles can be combined at the same time, or the two types of information can be used separately, such as E i =E r1′ (θ=0), or E i =E r1 (θ=1), similarly, the details are as follows:
[0198] f i r2 =H i ||E i
[0199]
[0200] Furthermore, we can get the vector f i r2 ∈R 2*2d , i∈[1,r2].
[0201] Finally, by constructing positive and negative sample pairs, sentences in the original conversation are used as positive samples, and sentences in the randomly sampled replacement conversation are used as negative samples. NT-Xent loSs is used as the loss function L to train the large language model. The loss function L is as follows:
[0202]
[0203] Among them, N is the number of all positive samples, and M is the number of all training sample pairs corresponding to a positive sample (f j , f j ′), j∈[1,M], (f i , f i ′) represents a positive sample and a sample pair with similar semantics. The neural network model is trained by minimizing the loss function.
[0204] Furthermore, after obtaining the sentence vector representation in the conversation, various tasks such as clustering, similarity calculation, intent recognition, sentiment analysis, and vector retrieval can be performed.
[0205] Furthermore, in practical applications, in order to automatically label topics for conversations, we can also use the learned vectors from the training to fuse all the sentence vectors in the conversation as the vector representation of the entire conversation, and obtain the vector representation df of the entire conversation of role r1. r1 ∈R 1*2d , the vectorized df of the entire conversation of role r2 r2 ∈R 1*2d , the dialogue vector df∈R 1*2d The calculation is as follows:
[0206]
[0207] Among them, the feedforward neural network (FFN) is a two-layer feedforward network plus the activation function ReLU, γ i is the weight corresponding to each sentence vector in a fusion dialogue, i represents any sentence in the entire dialogue, and the γ i That is, it represents the weight of the i-th sentence in the dialogue text, FFN(f i ) represents the result of the vector representation of the i-th sentence, r1 represents the number of times character r1 speaks, and r2 represents the number of times character r2 speaks. Deeply combining the dialogue scene and considering the context can enhance the relationship between dialogues of different characters, deeply evaluating the weight of each sentence, and making the vector representation smoother. Throughout the entire dialogue, the characters represent identities, and different identities have different corresponding social statuses. The feelings and status between the characters are deeply mined, and the switching of sub-topics of different dialogues in different rounds corresponds to the switching of various dimensions related to the dialogue topic. That is, the information of each dimension related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the characters, and the differences between different statuses and identities, making the vector representation more down-to-earth, which helps to improve the accuracy of subsequent topic classification.
[0208] Correspondingly, df can be obtained r1 , df r2 , as follows:
[0209]
[0210] Among them, i represents any sentence of role r1, and the γ i represents the weight of the i-th sentence in the partial dialogue text corresponding to the role r1, FFN(f i) represents the result of the vector representation of the i-th sentence, r1 represents the number of times character r1 speaks, and deeply combines the dialogue scene. Considering the context can enhance the connection between dialogues of different characters, deeply evaluate the weight of each sentence of the specified character, and the vector representation is smoother throughout the entire dialogue, which is helpful to deeply explore the characteristics of the role and improve the accuracy of subsequent topic classification.
[0211] Then, correspondingly, df can be obtained r2 , as follows:
[0212]
[0213] Among them, i represents any sentence of role r1, and the γ i represents the weight of the i-th sentence in the partial dialogue text corresponding to role r2, FFN(f i ) represents the result of the vector representation of the i-th sentence, r2 represents the number of times character r2 speaks, and deeply combines the dialogue scene. Considering the context can enhance the connection between dialogues of different characters, deeply evaluate the weight of each sentence of the specified character, and the vector representation is smoother throughout the entire dialogue, which is helpful to deeply explore the characteristics of the characters and improve the accuracy of subsequent topic classification.
[0214] Next, we can use these three different types of dialogue vectors of the entire conversation to label the topic of the entire conversation, classify the conversation by topic, input the vector converted from the entire conversation into the topic model, and obtain the corresponding topic classification label.
[0215] Let's take an example. Figure 1B As shown in the figure, a recording is obtained, and ASR is performed to obtain the translated dialogue text. When the dialogue text is generated based on GPT, the translated dialogue text and the generated dialogue text can be input into the sentence input model M to obtain the word vector. On the one hand, the sentence vector is obtained based on the word vector. On the other hand, the initial dialogue sentence vector is obtained, and the dialogue information embedding (sentence embedding, turn embedding, role embedding) is supplemented. Then, role embedding (self-interaction) and role embedding (interaction between roles) are performed. The sentence vector and the interaction results are spliced, and the splicing result is input into FFN for training to improve the model capability.
[0216] The dialogue text vector representation method described in the present application obtains a target dialogue text, the target dialogue text includes at least two roles, the target dialogue text includes at least one round of dialogue, the target dialogue text is processed into sentences to obtain multiple sentences, the multiple sentences are input into a first large language model to obtain multiple sentence vectors, the multiple sentence vectors are subjected to sentence embedding operations, role embedding operations and dialogue turn embedding operations to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors, the multiple sentence embedding sentence vectors, the multiple role embedding sentence vectors and the multiple dialogue turn embedding sentence vectors are added together to obtain a first sentence vector matrix, the first sentence vector matrix is input into a second large language model to obtain a second sentence vector matrix, a mask matrix of each of the at least two roles is obtained to obtain at least one mask matrix, and a mask matrix is generated based on the second sentence vector matrix and At least one mask matrix determines the sentence vector matrix of at least one character, and the sentence vector representation of the target dialogue text is determined according to the sentence vector matrix of at least one character. In this way, considering the context can enhance the connection between dialogues of different characters and guide the sub-layers between dialogue rounds, so that each round of dialogue can be smoothly connected in series, and the vector representation is also smoother. The characters represent identities, and different identities have different corresponding social statuses. The feelings and status between the characters are deeply mined, and the switching of sub-topics of different dialogues in different rounds corresponds to different dimensions. That is, the various dimensional information related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the characters, and the differences between different statuses and identities, making the vector representation more down-to-earth, which helps to improve the accuracy of subsequent topic classification.
[0217] In line with the above, see Figure 2 , Figure 2 FIG. 1 is a flow chart of another method for representing a conversation text vector provided in an embodiment of the present application. As shown in the figure, the method for representing a conversation text vector includes:
[0218] 201. Obtain a target dialogue text, where the target dialogue text includes at least two characters and at least one round of dialogue.
[0219] 202. Process the target dialogue text into sentences to obtain a plurality of sentences.
[0220] 203. Input the multiple sentences into a first large language model to obtain multiple sentence vectors.
[0221] 204. Perform sentence embedding operations, role embedding operations, and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors, and multiple dialogue turn embedding sentence vectors.
[0222] 205. Add the multiple sentence embedding sentence vectors, the multiple role embedding sentence vectors, and the multiple dialogue turn embedding sentence vectors to obtain a first sentence vector matrix.
[0223] 206. Input the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix.
[0224] 207. Obtain a mask matrix of each of the at least two roles to obtain at least one mask matrix.
[0225] 208. Determine a sentence embedding matrix for at least one role according to the second sentence embedding matrix and the at least one mask matrix.
[0226] 209. Determine a sentence vector representation of the target dialogue text according to the sentence vector matrix of the at least one role.
[0227] 210. Input the target conversation text sentence vector representation into a preset topic model to obtain a target topic classification label.
[0228] The detailed description of the above steps 201 to 210 can be found in Figure 1A The relevant steps of the described method for vector representation of conversation text are not repeated here.
[0229] The method for representing a dialogue text vector described in the present application obtains a target dialogue text, wherein the target dialogue text includes at least two roles and at least one dialogue round, divides the target dialogue text into sentences to obtain a plurality of sentences, inputs the plurality of sentences into a first large language model to obtain a plurality of sentence vectors, performs sentence embedding operations, role embedding operations and dialogue round embedding operations on the plurality of sentence vectors to obtain a plurality of sentence embedding sentence vectors, a plurality of role embedding sentence vectors and a plurality of dialogue round embedding sentence vectors, adds the plurality of sentence embedding sentence vectors, the plurality of role embedding sentence vectors and the plurality of dialogue round embedding sentence vectors to obtain a first sentence vector matrix, inputs the first sentence vector matrix into a second large language model to obtain a second sentence vector matrix, obtains a mask matrix for each of the at least two roles to obtain at least one mask matrix, and determines at least one role according to the second sentence vector matrix and the at least one mask matrix. The sentence vector matrix of the target dialogue text is determined according to the sentence vector matrix of at least one role, and the target dialogue text sentence vector representation is input into the preset topic model to obtain the target topic classification label. In this way, considering the context can enhance the relationship between different role dialogues and guide the sub-layer between dialogue rounds, so that each round of dialogue can be smoothly connected in series, and the vector representation is also smoother. The role represents the identity, and the corresponding social status is different for different identities. The feelings and status between the roles are deeply mined, and the switching of sub-topics corresponding to different dialogues in different rounds, that is, the various dimensional information related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the role, the difference between different status and identity, making the vector representation more down-to-earth, which is helpful to improve the accuracy of subsequent topic classification.
[0230] In accordance with the above embodiment, please refer to Figure 3 , Figure 3 : is a structural diagram of an electronic device provided in an embodiment of the present application. As shown in the figure, the electronic device includes a processor, a memory, a communication interface, and one or more programs. The one or more programs are stored in the memory and configured to be executed by the processor. In the embodiment of the present application, the program includes instructions for executing the following steps:
[0231] Acquire a target dialogue text, wherein the target dialogue text includes at least two characters and the target dialogue text includes at least one round of dialogue;
[0232] Processing the target dialogue text into sentences to obtain a plurality of sentences;
[0233] Inputting the plurality of sentences into a first large language model to obtain a plurality of sentence vectors;
[0234] Perform sentence embedding operations, role embedding operations, and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors, and multiple dialogue turn embedding sentence vectors;
[0235] Adding the plurality of sentence embedding vectors, the plurality of role embedding vectors, and the plurality of dialogue turn embedding vectors to obtain a first sentence vector matrix;
[0236] Inputting the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix;
[0237] Obtaining a mask matrix for each of the at least two roles to obtain at least one mask matrix;
[0238] Determine a sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix;
[0239] A sentence vector representation of a target dialogue text is determined according to the sentence vector matrix of the at least one role.
[0240] In some possible examples, in determining the target dialogue text sentence vector representation according to the sentence vector matrix of the at least one role, the program includes instructions for performing the following steps:
[0241] Determine a self-interaction sentence vector matrix and a role-interaction sentence vector matrix for each role according to the sentence vector matrix of the at least one role;
[0242] Determine a first sentence vector representation of each of the at least one role according to the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role and the sentence vector matrix of the at least one role;
[0243] Determine a second sentence vector representation of each of the at least one role according to the first sentence vector representation of each of the at least one role and the first sentence vector matrix;
[0244] The target dialogue text sentence vector representation is determined according to the second sentence vector representation of each role of the at least one role.
[0245] In some possible examples, in determining the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role according to the sentence vector matrix of the at least one role, the program includes instructions for performing the following steps:
[0246] Obtaining a first transposed matrix of a sentence vector matrix of a first role, where the first role is any role among the at least one role;
[0247] Determine a self-interaction sentence vector matrix of the first role according to the sentence vector matrix of the first role and the first transposed matrix;
[0248] Determine a second transposed matrix of a sentence vector matrix of a second role, where the second role is any role among the at least one role except the first role;
[0249] A role interaction sentence vector matrix of the first role is determined according to the sentence vector matrix of the first role and the second transposed matrix.
[0250] In some possible examples, in determining the first sentence vector representation of each role of the at least one role according to the self-interaction sentence vector matrix and the role interaction sentence vector matrix of each role and the sentence vector matrix of the at least one role, the program includes instructions for performing the following steps:
[0251] Determine a self-interaction sentence vector representation of the second role according to the self-interaction sentence vector matrix of the second role and the sentence vector matrix of the second role;
[0252] Determining a role sentence vector representation of the second role according to the role interaction sentence vector matrix of the second role and the sentence vector matrix of a third role; the third role is any role among the at least one role except the second role;
[0253] A first sentence vector representation of the second role is determined according to the self-interaction sentence vector representation and the role sentence vector representation.
[0254] In some possible examples, in determining the second sentence vector representation of each role in the at least one role according to the first sentence vector representation of each role of the at least one role and the first sentence vector matrix, the program includes instructions for performing the following steps:
[0255] Performing a weighted operation on the self-interaction sentence vector representation and the role sentence vector representation to obtain an intermediate sentence vector representation;
[0256] The first sentence vector matrix and the intermediate sentence vector representation are vector-concatenated to obtain a second sentence vector representation of the second role.
[0257] In some possible examples, in determining the sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix, the program includes instructions for performing the following steps:
[0258] Determine a third transposed matrix of a first mask matrix corresponding to a first role; the first mask matrix is any mask matrix in the at least one mask matrix; the first role is one of the at least one role;
[0259] A dot product operation is performed on the second sentence vector matrix and the third transposed matrix to obtain a sentence vector matrix of the first role.
[0260] In some possible examples, the above program also includes instructions for performing the following steps:
[0261] Taking the target dialogue text as a positive sample;
[0262] Randomly sampling and replacing sentences in the target dialogue text to obtain negative samples;
[0263] The first large language model and / or the second large language model are trained according to the positive samples, the negative samples and a preset loss function.
[0264] In some possible examples, the above program also includes instructions for performing the following steps:
[0265] Obtaining an audio file of the target conversation text;
[0266] Sampling the audio file to obtain corpus content;
[0267] According to the content of the corpus, dialogue sentences and dialogue scene expansion prompt words are sampled, and the dialogue sentences and the dialogue scene expansion prompt words are input into the first language model to expand the dialogue corpus as training samples to enhance the generalization ability of the first language model.
[0268] In some possible examples, the above program also includes instructions for performing the following steps:
[0269] The target conversation text sentence vector representation is input into a preset topic model to obtain a target topic classification label.
[0270] The electronic device described in the present application obtains a target dialogue text, the target dialogue text includes at least two roles, the target dialogue text includes at least one round of dialogue, divides the target dialogue text into sentences to obtain multiple sentences, inputs the multiple sentences into a first large language model to obtain multiple sentence vectors, performs sentence embedding operations, role embedding operations and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors, adds the multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors to obtain a first sentence vector matrix, inputs the first sentence vector matrix into a second large language model to obtain a second sentence vector matrix, obtains a mask matrix for each of the at least two roles to obtain at least one mask matrix, and generates a mask matrix based on the second sentence vector matrix and the at least one A mask matrix is used to determine the sentence vector matrix of at least one character, and the sentence vector representation of the target dialogue text is determined according to the sentence vector matrix of at least one character. In this way, considering the context can enhance the connection between dialogues of different characters and guide the sub-layer nature between dialogue rounds, so that each round of dialogue can be smoothly connected in series, and the vector representation is also smoother. The characters represent identities, and different identities have different corresponding social statuses. The feelings and status between the characters are deeply mined, and the switching of sub-topics of different dialogues in different rounds corresponds to the switching of various dimensions related to the dialogue topic, that is, the information of each dimension related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the characters, and the differences between different statuses and identities, making the vector representation more down-to-earth, which helps to improve the accuracy of subsequent topic classification.
[0271] Figure 4 4 is a functional unit block diagram of a conversation text vector representation device 400 involved in an embodiment of the present application. The conversation text vector representation device 400 includes: an acquisition unit 401, a sentence unit 402, an input unit 403, an embedding unit 404 and a determination unit 405, wherein:
[0272] The acquisition unit 401 is used to acquire a target dialogue text, wherein the target dialogue text includes at least two characters and the target dialogue text includes at least one round of dialogue;
[0273] The sentence segmentation unit 402 is used to segment the target dialogue text into sentences to obtain a plurality of sentences;
[0274] The input unit 403 is used to input the multiple sentences into the first large language model to obtain multiple sentence vectors;
[0275] The embedding unit 404 is used to perform sentence embedding operations, role embedding operations and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors; add the multiple sentence embedding sentence vectors, the multiple role embedding sentence vectors and the multiple dialogue turn embedding sentence vectors to obtain a first sentence vector matrix;
[0276] The input unit 403 is further used to input the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix;
[0277] The acquisition unit 401 is further configured to acquire a mask matrix of each of the at least two roles to obtain at least one mask matrix;
[0278] The determining unit 405 is used to determine the sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix; and determine the sentence vector representation of the target dialogue text according to the sentence vector matrix of the at least one role.
[0279] In some possible examples, in determining the sentence vector representation of the target dialogue text according to the sentence vector matrix of the at least one role, the determining unit 405 is specifically configured to:
[0280] Determine a self-interaction sentence vector matrix and a role-interaction sentence vector matrix for each role according to the sentence vector matrix of the at least one role;
[0281] Determine a first sentence vector representation of each of the at least one role according to the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role and the sentence vector matrix of the at least one role;
[0282] Determine a second sentence vector representation of each of the at least one role according to the first sentence vector representation of each of the at least one role and the first sentence vector matrix;
[0283] The target dialogue text sentence vector representation is determined according to the second sentence vector representation of each role of the at least one role.
[0284] In some possible examples, in determining the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role according to the sentence vector matrix of the at least one role, the determining unit 405 is specifically used to:
[0285] Obtaining a first transposed matrix of a sentence vector matrix of a first role, where the first role is any role among the at least one role;
[0286] Determine a self-interaction sentence vector matrix of the first role according to the sentence vector matrix of the first role and the first transposed matrix;
[0287] Determine a second transposed matrix of a sentence vector matrix of a second role, where the second role is any role among the at least one role except the first role;
[0288] A role interaction sentence vector matrix of the first role is determined according to the sentence vector matrix of the first role and the second transposed matrix.
[0289] In some possible examples, in determining the first sentence vector representation of each role of the at least one role according to the self-interaction sentence vector matrix and the role interaction sentence vector matrix of each role and the sentence vector matrix of the at least one role, the determining unit 405 is specifically used to:
[0290] Determine a self-interaction sentence vector representation of the second role according to the self-interaction sentence vector matrix of the second role and the sentence vector matrix of the second role;
[0291] Determining a role sentence vector representation of the second role according to the role interaction sentence vector matrix of the second role and the sentence vector matrix of a third role; the third role is any role among the at least one role except the second role;
[0292] A first sentence vector representation of the second role is determined according to the self-interaction sentence vector representation and the role sentence vector representation.
[0293] In some possible examples, in determining the second sentence vector representation of each role in the at least one role according to the first sentence vector representation of each role of the at least one role and the first sentence vector matrix, the determining unit 405 is specifically used to:
[0294] Performing a weighted operation on the self-interaction sentence vector representation and the role sentence vector representation to obtain an intermediate sentence vector representation;
[0295] The first sentence vector matrix and the intermediate sentence vector representation are vector-concatenated to obtain a second sentence vector representation of the second role.
[0296] In some possible examples, in determining the sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix, the determining unit 405 is specifically configured to:
[0297] Determine a third transposed matrix of a first mask matrix corresponding to a first role; the first mask matrix is any mask matrix in the at least one mask matrix; the first role is one of the at least one role;
[0298] A dot product operation is performed on the second sentence vector matrix and the third transposed matrix to obtain a sentence vector matrix of the first role.
[0299] In some possible examples, the conversation text vector representation device 400 is further specifically used for:
[0300] Taking the target dialogue text as a positive sample;
[0301] Randomly sampling and replacing sentences in the target dialogue text to obtain negative samples;
[0302] The first large language model and / or the second large language model are trained according to the positive samples, the negative samples and a preset loss function.
[0303] In some possible examples, the conversation text vector representation device 400 is further specifically used for:
[0304] Obtaining an audio file of the target conversation text;
[0305] Sampling the audio file to obtain corpus content;
[0306] According to the content of the corpus, dialogue sentences and dialogue scene expansion prompt words are sampled, and the dialogue sentences and the dialogue scene expansion prompt words are input into the first language model to expand the dialogue corpus as training samples to enhance the generalization ability of the first language model.
[0307] In some possible examples, the conversation text vector representation device 400 is further specifically used for:
[0308] The target conversation text sentence vector representation is input into a preset topic model to obtain a target topic classification label.
[0309] The dialogue text vector representation device described in the present application obtains a target dialogue text, the target dialogue text includes at least two roles, the target dialogue text includes at least one round of dialogue, divides the target dialogue text into sentences to obtain multiple sentences, inputs the multiple sentences into a first large language model to obtain multiple sentence vectors, performs sentence embedding operations, role embedding operations and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors, adds the multiple sentence embedding sentence vectors, multiple role embedding sentence vectors and multiple dialogue turn embedding sentence vectors to obtain a first sentence vector matrix, inputs the first sentence vector matrix into a second large language model to obtain a second sentence vector matrix, obtains a mask matrix for each of the at least two roles to obtain at least one mask matrix, and performs a mask matrix based on the second sentence vector matrix and At least one mask matrix determines the sentence vector matrix of at least one character, and the sentence vector representation of the target dialogue text is determined according to the sentence vector matrix of at least one character. In this way, considering the context can enhance the connection between dialogues of different characters and guide the sub-layers between dialogue rounds, so that each round of dialogue can be smoothly connected in series, and the vector representation is also smoother. The characters represent identities, and different identities have different corresponding social statuses. The feelings and status between the characters are deeply mined, and the switching of sub-topics of different dialogues in different rounds corresponds to different dimensions. That is, the various dimensional information related to the dialogue topic can be mined from different dimensions, so that the final dialogue text sentence vector representation is more in line with the actual application scenario of the topic, and also covers the personality and commonality of the characters, and the differences between different statuses and identities, making the vector representation more down-to-earth, which helps to improve the accuracy of subsequent topic classification.
[0310] It can be understood that the functions of each program module of the conversation text vector representation device of this embodiment can be specifically implemented according to the method in the above method embodiment. The specific implementation process can refer to the relevant description of the above method embodiment, which will not be repeated here.
[0311] An embodiment of the present application also provides a computer storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method described in the above method embodiments, and the above computer includes an electronic device.
[0312] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.
[0313] It should be noted that, for the aforementioned method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described order of actions, because according to the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0314] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0315] In the several embodiments provided in the present application, it should be understood that the disclosed system can be implemented in other ways. For example, the system embodiments described above are only schematic, such as the division of the above-mentioned units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, and the indirect coupling or communication connection of the system or unit can be electrical or other forms.
[0316] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0317] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0318] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the above-mentioned methods of each embodiment of the present application. The aforementioned memory includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or CD-ROM and other media that can store program codes.
[0319] A person skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated as: ROM), a random access memory (English: Random Access Memory, abbreviated as: RAM), a magnetic disk or an optical disk, etc.
[0320] The embodiments of the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application. At the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A method for representing a conversation text vector, characterized in that: The method comprises: Acquire a target dialogue text, wherein the target dialogue text includes at least two characters and the target dialogue text includes at least one round of dialogue; Processing the target dialogue text into sentences to obtain a plurality of sentences; Inputting the plurality of sentences into a first large language model to obtain a plurality of sentence vectors; Perform sentence embedding operations, role embedding operations, and dialogue turn embedding operations on the multiple sentence vectors to obtain multiple sentence embedding sentence vectors, multiple role embedding sentence vectors, and multiple dialogue turn embedding sentence vectors; Adding the plurality of sentence embedding sentence vectors, the plurality of role embedding sentence vectors, and the plurality of dialogue turn embedding sentence vectors to obtain a first sentence vector matrix; Inputting the first sentence vector matrix into the second largest language model to obtain a second sentence vector matrix; Obtaining a mask matrix for each of the at least two roles to obtain at least one mask matrix; Determine a sentence vector matrix of at least one role according to the second sentence vector matrix and the at least one mask matrix; A sentence vector representation of a target dialogue text is determined according to the sentence vector matrix of the at least one role.
2. The method according to claim 1, characterized in that The determining the target dialogue text sentence vector representation according to the sentence vector matrix of the at least one role includes: Determine a self-interaction sentence vector matrix and a role-interaction sentence vector matrix for each role according to the sentence vector matrix of the at least one role; Determine a first sentence vector representation of each of the at least one role according to the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role and the sentence vector matrix of the at least one role; Determine a second sentence vector representation of each of the at least one role according to the first sentence vector representation of each of the at least one role and the first sentence vector matrix; The target dialogue text sentence vector representation is determined according to the second sentence vector representation of each role of the at least one role.
3. The method according to claim 2, characterized in that The determining of the self-interaction sentence vector matrix and the role-interaction sentence vector matrix of each role according to the sentence vector matrix of the at least one role includes: Obtaining a first transposed matrix of a sentence vector matrix of a first role, where the first role is any role among the at least one role; Determine a self-interaction sentence vector matrix of the first role according to the sentence vector matrix of the first role and the first transposed matrix; Determine a second transposed matrix of a sentence vector matrix of a second role, where the second role is any role among the at least one role except the first role; A role interaction sentence vector matrix of the first role is determined according to the sentence vector matrix of the first role and the second transposed matrix.
4. The method according to claim 3, characterized in that The determining, according to the self-interaction sentence vector matrix of each role and the role-interaction sentence vector matrix of the at least one role and the sentence vector matrix of the at least one role, a first sentence vector representation of each role of the at least one role comprises: Determine a self-interaction sentence vector representation of the second role according to the self-interaction sentence vector matrix of the second role and the sentence vector matrix of the second role; Determining a role sentence vector representation of the second role according to the role interaction sentence vector matrix of the second role and the sentence vector matrix of a third role; the third role is any role among the at least one role except the second role; A first sentence vector representation of the second role is determined according to the self-interaction sentence vector representation and the role sentence vector representation.
5. The method according to claim 4, characterized in that The determining, according to the first sentence vector representation of each role of the at least one role and the first sentence vector matrix, a second sentence vector representation of each role of the at least one role comprises: Performing a weighted operation on the self-interaction sentence vector representation and the role sentence vector representation to obtain an intermediate sentence vector representation; The first sentence vector matrix and the intermediate sentence vector representation are vector-concatenated to obtain a second sentence vector representation of the second role.
6. The method according to any one of claims 2 to 5, characterized in that: The determining, according to the second sentence vector matrix and the at least one mask matrix, a sentence vector matrix of at least one role includes: Determine a third transposed matrix of a first mask matrix corresponding to a first role; the first mask matrix is any mask matrix in the at least one mask matrix; the first role is one of the at least one role; A dot product operation is performed on the second sentence vector matrix and the third transposed matrix to obtain a sentence vector matrix of the first role.
7. The method according to claim 6, characterized in that The method further comprises: Taking the target dialogue text as a positive sample; Randomly sampling and replacing sentences in the target dialogue text to obtain negative samples; The first large language model and / or the second large language model are trained according to the positive samples, the negative samples and a preset loss function.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: Obtaining an audio file of the target conversation text; Sampling the audio file to obtain corpus content; According to the content of the corpus, dialogue sentences and dialogue scene expansion prompt words are sampled, and the dialogue sentences and the dialogue scene expansion prompt words are input into the first language model to expand the dialogue corpus as training samples to enhance the generalization ability of the first language model.
9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: The target conversation text sentence vector representation is input into a preset topic model to obtain a target topic classification label.
10. A computer-readable storage medium, characterized in that: A computer program for electronic data exchange is stored, wherein the computer program enables a computer to execute the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Text vector representation method and text vector representation device
CN106815244A
Text processing method and system based on sentence vector pre-training model and storage medium
CN112182231A
Text translation method, device, electronic equipment and computer readable storage medium
CN113569584A
Role marking and speech synthesis method, device and system and storage medium
CN115062585A
Semantic vector model pre-training method based on multi-mask mode
CN117952151A
