Dialogue text processing method and device, computer equipment and storage medium
Through the text vector of dialogue text, entity extraction, normalization processing and affirmative statement screening, the problem of low accuracy of symptom entity recognition in online medical consultation systems is solved, and diagnostic accuracy and user experience are improved.
Patent Information
- Application Number
- CN202411736148.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2044-11-27
AI Technical Summary
In the existing online medical consultation system, the symptom entity described by patients is non-professional term, resulting in low entity recognition accuracy, affecting diagnostic accuracy and user experience.
By extracting and normalizing the text vectors of the dialogue text, and filtering them based on affirmative statements, the target entity of the dialogue text is determined.
Improve the accuracy of the target entity in the dialogue text, making the target entity more in line with text semantic information, and improves diagnostic accuracy and user experience.
Smart Images

Figure CN119783686A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of artificial intelligence and medical health, and in particular to a conversation text processing method, device, computer equipment and storage medium. Background Art
[0002] Natural language processing methods for understanding conversational scenarios are widely used in online stores, online pharmacies, online medical consultation systems, etc., and can automatically respond to users' questions. For example, in online medical consultation systems, in order to improve the efficiency of disease diagnosis and reduce the workload of doctors, major medical institutions have launched convenient intelligent consultation systems. By asking users with diagnosis needs multiple questions about their personal symptoms, and comparing the symptom information collected in each conversation with the symptom information that may appear in various diseases, the disease with the closest symptoms is gradually identified in the continuous matching process. This type of solution mainly terminates the inquiry and outputs the diagnosis result through preset values on parameters such as conversation rounds or matching degree. For example, in online medical consultation systems, users can conduct health consultations or consultations online.
[0003] However, at present, these online health consultations and medical consultations, etc., have a low accuracy rate in matching symptom entities with standard entities, because in actual situations, the symptom entities described by patients are not professional terms, which affects the accuracy of diagnosis and reduces the user experience. Summary of the invention
[0004] The present invention provides a dialogue text processing method, device, computer equipment and storage medium to solve the current technical problem of low accuracy of entity recognition in dialogue text.
[0005] In a first aspect, an embodiment of the present invention provides a method for processing a conversation text, the method comprising:
[0006] Perform entity extraction on the text vector of the conversation text to obtain multiple text entities;
[0007] Normalizing each of the text entities to obtain a normalized entity corresponding to each of the text entities;
[0008] According to the text vector and each of the text entities, each of the normalized entities is screened based on the affirmative sentence to obtain a target normalized entity in the affirmative sentence;
[0009] According to the target normalized entity, a target entity corresponding to the dialogue text is determined.
[0010] In a second aspect, an embodiment of the present invention further provides a conversation text processing device, the device comprising:
[0011] A text entity acquisition module is used to extract entities from the text vector of the conversation text to obtain multiple text entities;
[0012] A normalized entity acquisition module, used for normalizing each of the text entities to obtain a normalized entity corresponding to each of the text entities;
[0013] A target normalized entity acquisition module, used to screen each of the normalized entities based on the affirmative sentence according to the text vector and each of the text entities, to obtain a target normalized entity in the affirmative sentence;
[0014] A target entity determination module is used to determine a target entity corresponding to the dialogue text according to the target normalized entity.
[0015] In a third aspect, an embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned conversation text processing method when executing the computer program.
[0016] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned conversation text processing method are implemented.
[0017] In the scheme implemented by the above-mentioned dialogue text processing method, device, computer equipment and storage medium, multiple text entities can be obtained by performing entity extraction on the text vector of the dialogue text. Each text entity is normalized to obtain a normalized entity corresponding to each text entity, and each normalized entity is screened based on the affirmative sentence according to the text vector and each text entity to obtain the target normalized entity in the affirmative sentence. According to the target normalized entity, the target entity corresponding to the dialogue text is determined. The embodiment of the present invention realizes obtaining text entities according to text vectors, and then normalizing the text entities to standardize the text entities, and then judging the normalized entities obtained by the normalization for affirmative sentences, and screening out the normalized entities in the affirmative sentences as the target entities of the dialogue text. Since the normalized entities in the negative sentences are eliminated, the target entity is more consistent with the text semantic information in the dialogue text, so that the target entity is more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0019] Figure 1 is a schematic diagram of an application environment of a conversation text processing method in one embodiment of the present invention;
[0020] Figure 2 is a flow chart of a method for processing a conversation text in one embodiment of the present invention;
[0021] Figure 3 is a structural schematic diagram of a conversation text processing device in one embodiment of the present invention;
[0022] Figure 4 is a schematic diagram of the structure of a computer device in one embodiment of the present invention;
[0023] Figure 5 It is a structural schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION
[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0025] The dialog text processing method provided by the embodiment of the present invention can be applied in the following aspects: Figure 1 In an application environment, the client communicates with the server through a network. The server can receive the conversation text through the client, and obtain multiple text entities by performing entity extraction on the text vector of the conversation text. Each text entity is normalized to obtain a normalized entity corresponding to each text entity, and each normalized entity is screened based on the affirmative sentence according to the text vector and each text entity to obtain a target normalized entity in the affirmative sentence. According to the target normalized entity, the target entity corresponding to the conversation text is determined. The target entity is fed back to the client.
[0026] At present, consultation and medical consultation platforms are very popular among users. Users can communicate with the platform at any time. Even if there is no manual response, robots can still respond to solve users' urgent problems. For example, medical consultation apps can realize online health consultation and medical consultation, etc. However, since the symptoms often described by users are not professional terms, the accuracy of matching the symptom entities in the user's description text with the standard entities is not high, which in turn leads to the lack of fit between the answer obtained based on the wrong matching standard entity and the user's description text, that is, the response fed back to the user is not accurate enough, affecting the user experience.
[0027] Therefore, the embodiment of the present invention obtains text entities through text vectors, and then normalizes the text entities to standardize the text entities, and then judges the normalized entities obtained by the normalization process for affirmative sentences, and screens out the normalized entities in the affirmative sentences as the target entities of the dialogue text. The scheme of the embodiment of the present invention improves the accuracy of the target entities in the dialogue text. Among them, the client can be but is not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented with an independent server or a server cluster composed of multiple servers. The present invention is described in detail below through specific embodiments.
[0028] In one embodiment of the present invention, a method for processing a conversation text is provided. The method for processing a conversation text in the embodiment of the present invention can be used to identify entities in a conversation text. The method for processing a conversation text in the embodiment of the present invention can be executed by a conversation text processing device, wherein the conversation text device can be implemented in the form of software and / or hardware. Figure 2 As shown, the dialogue text processing method provided by the embodiment of the present invention specifically includes the following steps:
[0029] S110, performing entity extraction on the text vector of the conversation text to obtain multiple text entities.
[0030] Among them, the dialogue text includes the dialogue text of medical consultation and health consultation, including the dialogue text between users and doctors, and between users and systems. For example, in a health consultation app, the dialogue between users and doctors on an online platform, or the system can identify and match the appropriate reply text based on the text entered by the user to communicate with the user. The dialogue text can also be the dialogue text of users on online shopping platforms when shopping, such as the dialogue text between users and merchants. The dialogue text can also be some information platforms.
[0031] For example, if the dialogue text is a medical consultation, it can be: A: I have a headache, sore throat, and a high fever of 39 degrees. B: Do you cough? A: No. It should be understood that A and B are only used to distinguish the two parties in the dialogue and have no actual meaning.
[0032] Specifically, entity extraction is performed on the text vector of the conversation text to obtain multiple text entities. This step realizes the extraction of text entities in the conversation text and prepares for subsequent entity normalization.
[0033] Optionally, the text entities of the text vector of the dialogue text can be extracted by an entity recognition method to obtain multiple text entities. The entity recognition method includes a Chinese named entity recognition (NER) algorithm, and the named entity recognition algorithm includes but is not limited to a named entity recognition method based on rules and dictionaries, a named entity recognition method based on statistical machine learning, a named entity recognition method based on deep learning, and a named entity recognition method based on an attention mechanism.
[0034] It should be noted that in the embodiment of the present invention, after obtaining the conversation text, the conversation text is vectorized and represented, which can be achieved by embedding the embedding layer of the bidirectional long short-term memory model (Bi-directional Long Short-Term Memory, BiLSTM) to obtain a text vector.
[0035] S120: performing normalization processing on each of the text entities to obtain a normalized entity corresponding to each of the text entities.
[0036] Specifically, each text entity is normalized respectively to obtain a normalized entity corresponding to each text entity, thereby achieving standardization of text entities and preparing for subsequent screening of normalized entities in affirmative sentences.
[0037] S130 . Screening each of the normalized entities based on the affirmative sentence according to the text vector and each of the text entities to obtain a target normalized entity in the affirmative sentence.
[0038] Specifically, the position of each text entity in the text vector can be determined according to the text vector, and the text entity in the affirmative sentence can be determined according to the position and the text vector, and then the normalized entity corresponding to the text entity in the affirmative sentence is used as the target normalized entity. The scheme of the embodiment of the present invention realizes judging whether each sentence in the dialogue text is an affirmative sentence or a negative sentence according to the text vector. According to the position of the text entity in the text vector, it is judged whether the text entity is located in the affirmative sentence, and the normalized entity corresponding to the text entity located in the affirmative sentence is used as the target normalized entity, thereby improving the accuracy of determining the target normalized entity in the dialogue text. An affirmative sentence is, for example: "B: Do you cough? A: Yes". Or, the affirmative sentence can also be: "A: I have a headache. B: Got it".
[0039] S140. Determine a target entity corresponding to the conversation text according to the target normalized entity.
[0040] The target entity refers to the final text entity obtained in the dialogue text.
[0041] Specifically, in an embodiment of the present invention, a target entity corresponding to the dialogue text is determined based on the target normalized entity, so that the target entity in the dialogue text is more accurate. Optionally, the target normalized entity is used as the target entity of the dialogue text.
[0042] The method for processing a dialogue text of an embodiment of the present invention obtains a plurality of text entities by performing entity extraction on the text vector of the dialogue text. Each text entity is normalized to obtain a normalized entity corresponding to each text entity, and each normalized entity is screened based on affirmative sentences according to the text vector and each text entity to obtain a target normalized entity in the affirmative sentence. According to the target normalized entity, a target entity corresponding to the dialogue text is determined. The embodiment of the present invention realizes obtaining a text entity according to a text vector, and then normalizing the text entity to standardize the text entity, and then judging the normalized entity obtained by the normalization for affirmative sentences, and screening out the normalized entity in the affirmative sentence as the target entity of the dialogue text. Since the normalized entity in the negative sentence is eliminated, the target entity is more consistent with the text semantic information in the dialogue text, and thus the target entity is more accurate.
[0043] In another embodiment of the present invention, each of the text entities is normalized to obtain a normalized entity corresponding to each of the text entities, including: matching each preset standard entity and each of the text entities through a pre-trained normalization model to obtain a matching degree between each text entity and each standard entity; for each of the text entities, taking the standard entity with the highest matching degree as the normalized entity of the text entity.
[0044] Among them, the normalization model is pre-trained. The normalization model includes but is not limited to a wide and deep model (Wide&Deep model), a single hidden layer neural network recommendation model (AutoRec model), etc. Standard entities refer to various pre-set entity terms that are the same or similar to professional terms. For example, standard entities can be: "headache", "dull headache", "intermittent headache", etc. Optionally, standard entities can be stored in a standard entity library, and each standard entity is obtained when normalizing text entities.
[0045] Specifically, through the pre-trained normalization model, the pre-set standard entities and the text entities are matched to obtain the matching degree between each text entity and each standard entity. For each text entity, the standard entity with the highest matching degree is used as the normalized entity of the text entity. The embodiment of the present invention realizes the normalization processing of text entities and realizes the standardization of text entities.
[0046] In another embodiment of the present invention, before normalizing the text entity, it is preferred to extract some candidate standard entities corresponding to each text entity from the standard entity library. The extraction method can perform similarity matching between the text entity and each standard entity in the standard entity library to obtain some candidate standard entities corresponding to each text entity. For each text entity, the text entity is matched with each corresponding candidate entity through a normalization model to obtain the matching degree between the text entity and each candidate entity, and the candidate standard entity with the highest matching degree is used as the normalized entity of the text entity. Through the scheme of the embodiment of the present invention, each text entity is no longer matched with each standard entity, but firstly recalls some candidate standard entities for each text entity, so that when each text entity and each candidate standard entity are matched through the normalization model, the workload of the normalization model can be reduced, the performance of the normalization model can be improved, and the efficiency of the normalization processing of the text entity can be improved.
[0047] In another embodiment of the present invention, before the pre-trained normalized model is used to match the preset standard entities and the text entities to obtain the matching degree of each text entity with each standard entity, the method further includes: normalizing each training sample pair through the initial model to obtain a normalized processing result, wherein the training sample pair includes a training text entity, a positive sample of the training text entity, and a negative sample of the training text entity; inputting the normalized processing result into a loss function to obtain a first loss value; when the first loss value does not meet the preset loss condition, adjusting the model parameters of the initial model and continuing training; when the first loss value meets the loss condition or the number of iterations reaches a threshold number, using the initial model as a normalized model.
[0048] Among them, each training sample is a training text entity, a positive sample of the training text entity, and a negative sample of the training text entity. The positive sample of the training text entity may refer to a term that is the same or similar to the training text entity. For example, if the training text entity is: "headache", the positive sample may include "dull headache" or "intermittent headache". The negative sample of the training text entity may refer to a term that is different from the training text entity. For example, if the training text entity is: "headache", the negative sample may include: "dry throat", etc. The loss conditions include but are not limited to the convergence of the loss value, the loss value being less than a preset loss threshold, and the loss value being within the loss threshold range.
[0049] Specifically, each training sample pair is processed by the initial model to obtain a normalized processing result, and the normalized processing result is input into the loss function. After obtaining the first loss value, it is determined whether the first loss value meets the loss condition. If it does not meet the loss condition, the model parameters of the initial model are adjusted to obtain an updated initial model. Each training sample pair is processed by the updated initial model to obtain a normalized processing result, and then a new first loss value is obtained. It is determined whether the new first loss value meets the loss condition. If it does not meet the loss condition, the model parameters of the initial model are adjusted, and the training is repeated until the first loss value meets the loss condition, and the training is stopped. If the loss condition is met, the initial model at this time is used as the normalized model. The scheme of the embodiment of the present invention realizes the training of the normalized model.
[0050] In another embodiment of the present invention, the normalization model is a Wide & Deep model with a pariwise structure. The Wide part can perform preliminary processing on the text entity and the standard entity based on the sorted rule base such as the named body related to the text entity, the antonym of the text entity, the synonym of the text entity, the degree word of the text entity, etc., to obtain the first matching degree between the text entity and each standard entity. The named body related to the text entity includes if the text entity is a disease, the related named body can be a limb or body part, if the text entity includes an occupation, the named body includes years of work, etc. It should be understood that the words in the rule base can be set as needed, and the named body related to the text entity can also be set as needed. The Deep part can use the Enhanced Sequential Inference Model (ESIM) to match the text entity and the standard entity to obtain a second matching degree. Based on the first matching degree and the second matching degree, the matching degree of the text entity processed by the normalized model and the standard entity is obtained.
[0051] During the training phase, the wide part processes the training text entities, the positive samples of the training text entities, and the negative samples of the training text entities to obtain the first matching degree between the training text entities and the positive samples, and the first matching degree between the training text entities and the negative samples. Similarly, the deep part also obtains the second matching degree between the training text entities and the positive samples, and the second matching degree between the training text entities and the negative samples. Based on the first matching degree and the second matching degree between the training text entities and the negative samples, the matching degree between the training text entities and the negative samples is obtained, and similarly, the matching degree between the training text entities and the positive samples is obtained. The matching degree between the training text entities and the negative samples and the matching degree between the training text entities and the positive samples are input into the loss function to calculate the first loss value. When the first loss value converges, the initial model can be used as the normalized model. The loss function is expressed as:
[0052] L(a,p,n)=max(0,-f(a,p)+f(a,n)+margin)
[0053] Wherein, L represents the loss function, a represents the training text entity, p represents the positive sample, n represents the negative sample, and f(a,p) is the matching degree obtained by inputting the training text entity and the positive sample into the normalized model. max is the maximum value. f(a,n) is the matching degree obtained by inputting the training text entity and the negative sample into the normalized model. Optionally, margin is a hyperparameter. The matching degree can be a score, for example, the matching degree b∈[0,1]. It should be understood that when the matching degree is 1, it means that the training text entity is exactly the same as the positive sample, and when the matching degree is 0, it means that the training text entity is completely different from the negative sample. It should be understood that in the training stage, the initial model can be trained using the training sample set, that is, multiple training text entities, positive samples of each training text entity, and negative samples of each training text entity are input at the same time.
[0054] It should be understood that the text entities, training text entities, positive samples, negative samples, etc. in the embodiments of the present invention are all represented in the form of vectors.
[0055] During the use phase of the normalization model, the matching degree between each text entity and each standard entity is obtained through wide and deep processing. According to the pariwise sorting, the standard entity with the highest matching degree is used as the normalized entity of the text entity. In addition, when sorting the standard entities corresponding to the matching degree according to pariwise, the preset number of standard entities can also be used as the intermediate normalized entities of the text entity. The intermediate normalized entity can be used as the reference target entity of the dialogue text, and the reference target entity can be fed back to the staff to facilitate the staff to quickly understand the content of the dialogue text.
[0056] In another embodiment of the present invention, the entity extraction of the text vector of the conversation text to obtain multiple text entities includes: performing entity extraction on the text vector through a pre-trained semantic acquisition model to obtain a target text vector, wherein the target text vector includes contextual semantic information of the conversation text; and obtaining multiple text entities by processing the target text vector.
[0057] The semantic acquisition model can refer to a multi-corpus interactive information model, or other models that can obtain contextual semantic information in a conversation text. In a conversation text, a text entity may appear in multiple sentences, but the embeddings of the same text entity obtained by BiLSTM in different sentences are different because the embedding contains the context information of each sentence. Therefore, by interacting the embeddings of the same word in each sentence, the content of the entire conversation can be fully utilized, so that there is more sufficient information to determine whether a symptom expresses a positive or negative attitude at the current position.
[0058] Specifically, in the embodiment of the present invention, entity extraction is performed on the text vector through a pre-trained semantic acquisition model to obtain a target text vector having contextual semantic information of the conversation text. By processing the target text vector, a pair of text entities are obtained. Since the solution of the embodiment of the present invention extracts the contextual semantic information in the conversation text, the text entity is extracted according to the target text vector, so that the text entity also has semantic information, and thus when the target normalized entity in the subsequent affirmative sentence is screened, the screened target normalized entity can be made more accurate.
[0059] For example, in the training phase of the semantic acquisition model: the jth training text entity m of the i-th sentence in the training dialogue text ij , whose embedding is h ij , find all the same training text entities m in the rest of the sentences in the training dialogue text ij (Assuming that the lth training text entity m in the kth sentence k1 =m ij For example), and get its corresponding embedding (egh kl ), the training text entity vectors of these training text entities and h ij The attention layer is performed separately and the corresponding weight score is obtained through the normalized exponential function softmax, that is, a ij , then we get the training text entity vector H based on the entire training dialogue text ij express:
[0060]
[0061] Among them, K is the number of m in the entire training dialogue text. ij The number of occurrences of h ij Represents the training text entity m ij embedding, m represents the training text entity.
[0062] Through the above method, the vector of each training text entity in the training dialogue text can be obtained. Similarly, if a training text entity appears in multiple training dialogue texts and can have different meanings in different contexts, the vector representation of each training text entity in multiple training dialogue texts in the entire corpus can be calculated, and the problem of semantic ambiguity can be reduced through the information of the training dialogue texts in the entire corpus. The embedding layer (embedding) of each training text entity itself, its in-dialogue attention layer (attention) vector representation, and the out-dialogue attention layer (attention) vector representation are spliced, and then the BiLSTM model is used to learn context features to realize the training of the multi-text interactive information model. The semantic acquisition model trained in this way can improve the semantic representation ability in the text vector when acquiring the semantic text vector of the dialogue text.
[0063] In another embodiment of the present invention, the normalized entities are screened based on affirmative sentences according to the text vector and each text entity to obtain a target normalized entity in the affirmative sentence, including: inputting the target text vector and each text entity into a pre-trained entity screening model to obtain the text entity in the affirmative sentence; and taking the normalized entity corresponding to the text entity in the affirmative sentence as the target normalized entity.
[0064] Among them, the pre-trained entity screening model can be a neural network model.
[0065] Specifically, the target text vector and each text entity are input into the pre-trained entity screening model to obtain the text entity in the affirmative sentence, and the normalized entity corresponding to the text entity in the affirmative sentence is used as the target normalized entity. In the embodiment of the present invention, the affirmative sentence and the negative sentence in the dialogue text can be judged according to the text vector, and the text vector in the affirmative sentence and the text vector in the negative sentence can be obtained by the position of the text entity in the dialogue text. The output of the entity screening model can be a mark of each text entity as an affirmative sentence or a negative sentence. For example, if the text entity is in the affirmative sentence, a mark 1 is added to the text entity, and if the text entity is in the negative sentence, a mark 0 is added to the text entity. The technical solution of the embodiment of the present invention can filter out the text entity in the affirmative sentence from the text entity, and determine the normalized entity corresponding to the text entity in the affirmative sentence as the target normalized entity, thereby improving the accuracy of determining the target normalized entity.
[0066] In another embodiment of the present invention, before the target text vector and each text entity are input into a pre-trained entity screening model to obtain the text entity in the affirmative sentence, the method further includes: processing the training text vector and the training text entity through the initial entity screening model to obtain a training entity screening result; obtaining a second loss value according to the training entity screening result, the true label corresponding to the training entity screening result, and the entity relevance loss value, and completing the training when the second loss value meets the training condition, and using the trained initial entity screening model as the entity screening model, wherein the entity relevance loss value is determined by the co-occurrence frequency of the training normalized entity corresponding to the training text entity and the candidate standard entity, and the candidate standard entity includes each standard entity in the standard entity library except the training normalized entity.
[0067] Among them, the co-occurrence frequency refers to the frequency of occurrence between every two standard entities in the pre-acquired standard entity library in the training dialogue text. For every two standard entities, the co-occurrence frequency of every two standard entities is obtained through each training dialogue text. The pre-acquired co-occurrence frequency can be obtained based on the two standard entities. The training text entity is obtained based on the training text vector, and the training normalized entity is obtained by normalizing the training text entity. Each training text entity is set with a true label, and the true label refers to whether the sentence in which the training text entity is located is an affirmative sentence or a negative sentence.
[0068] Specifically, the training text vectors and training text entities are processed through the initial entity screening model to obtain the training text entity screening results, and the training text entity screening results, the true labels corresponding to the training text entity screening results, and the entity relevance loss values are input into the second loss function to obtain the second loss value. When the second loss value meets the training conditions, the training is completed and the initial entity screening model at this time is used as the entity screening model. If the second loss value does not meet the training conditions, the model parameters of the initial entity screening model are adjusted and the training continues. It should be understood that in the implementation of the present invention, when training the initial entity screening model, multiple training text vectors and multiple training text entities in each training text vector can be used at the same time to reduce the training time of the initial entity model.
[0069] The second loss function expresses the weighted sum of the cross entropy loss value of the training text entity screening result and the true label and the entity relevance loss value. The training text entity screening result can be a score corresponding to the training text entity, which is used to indicate that the training text entity is located in a positive sentence. The true label can be 1 or 0, 1 indicates that the training text entity is located in a positive sentence, and 0 indicates that the training text entity is located in a negative sentence. In this way, the cross entropy loss value of the training text entity screening result and the true label is obtained, and the cross entropy loss value and the entity relevance loss value are weighted and summed to obtain the second loss value.
[0070] The entity relevance loss value can be calculated by the following expression:
[0071]
[0072] Among them, w i,j is the training text entity y i With the training text entity y j , y represents the co-occurrence frequency between training text entities, i and j are used to distinguish different training text entities, i is not equal to j, i = 1, 2, ... n, j = 1, 2, ... n. The entity relevance loss value can be used to indicate the possibility of co-occurrence of training text entities in the training dialogue text. The larger S is, the lower the possibility is, that is, the lower the relevance between training text entities is.
[0073] In another embodiment of the present invention, after determining the target entity corresponding to the conversation text according to the target normalized entity, the method further includes: obtaining a target reply text corresponding to the target entity according to a mapping relationship between each standard entity and the reply text.
[0074] Among them, the reply text corresponding to each standard entity is preset, and the reply text corresponding to each standard entity includes: the reply text corresponding to each standard entity, the reply text of several different standard entities, etc. A reply text library can be set, and each reply text has at least one corresponding standard entity. There is a corresponding relationship between the reply text and the corresponding at least one standard entity.
[0075] Specifically, according to the mapping relationship between each standard entity and the reply text, the target reply text corresponding to the target entity is obtained. The technical solution of the embodiment of the present invention realizes that after obtaining the target entity, the reply text can be obtained, and by feeding back the reply text to the user, the user can get a reply at the end of the conversation, thereby improving the user experience.
[0076] In an embodiment of the present invention, the reply text can be fed back to the user through the display page. For example, in a health consultation APP, in the dialogue window, the user enters symptoms, the robot or doctor replies, and the dialogue text between the two is obtained in real time, and the target entity is obtained according to the dialogue text. According to the target entity, the reply text is determined and fed back to the dialogue window, so that the user can know his or her own diagnosis and treatment results according to the symptoms. Since the accuracy of the target entity determination in the embodiment of the present invention is relatively high, the accuracy of the reply text obtained according to the target entity is also improved, so that the user can accurately understand his or her own condition, improving the user experience.
[0077] Exemplarily, a dialogue text is obtained from the dialogue window, including "I have a headache and a fever of 39 degrees. Do you have a cough? No.", and "headache" and "high fever" are obtained from the dialogue text. According to the correspondence between "headache" and "high fever" and the standard entity and the reply text, the reply text is obtained as "If you have a cold, it is recommended to take medicine A. If the high fever does not subside, it is recommended to seek medical attention in time". Of course, the reply text in the reply text library can be updated at any time as needed. The scheme of the embodiment of the present invention can obtain the reply text according to the target entity, reduce the workload of the doctor, and can reply to the user in time, thereby improving the user experience.
[0078] In another embodiment of the present invention, a conversation text processing device is also provided. The conversation text processing device provided by the present invention can execute the conversation text processing method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method. Figure 3 As shown, the device includes: a text entity acquisition module 410, a normalized entity acquisition module 420, a target normalized entity acquisition module 430 and a target entity determination module 440, wherein:
[0079] A text entity acquisition module 410 is used to perform entity extraction on the text vector of the dialogue text to obtain multiple text entities; a normalized entity acquisition module 420 is used to perform normalization processing on each of the text entities to obtain a normalized entity corresponding to each of the text entities; a target normalized entity acquisition module 430 is used to perform screening on each of the normalized entities based on affirmative sentences according to the text vector and each of the text entities to obtain a target normalized entity in the affirmative sentence; a target entity determination module 440 is used to determine a target entity corresponding to the dialogue text according to the target normalized entity.
[0080] In another embodiment of the present invention, the normalized entity acquisition module 420 includes:
[0081] The text entity matching submodule is used to match each preset standard entity and each of the text entities through a pre-trained normalization model to obtain a matching degree between each text entity and each standard entity;
[0082] The normalized entity determination submodule is used to use the standard entity with the highest matching degree as the normalized entity of the text entity for each of the text entities.
[0083] In another embodiment of the present invention, the text entity matching submodule includes:
[0084] A normalization processing result acquisition unit, used to perform normalization processing on each training sample pair through an initial model to obtain a normalization processing result, wherein the training sample pair includes a training text entity, a positive sample of the training text entity, and a negative sample of the training text entity;
[0085] A first loss value obtaining unit, used for inputting the normalization processing result into a loss function to obtain a first loss value;
[0086] A model parameter adjustment unit, configured to adjust the model parameters of the initial model and continue training when the first loss value does not meet a preset loss condition;
[0087] A normalized model obtaining unit is used to use the initial model as a normalized model when the first loss value satisfies the loss condition.
[0088] In another embodiment of the present invention, the text entity acquisition module 410 includes:
[0089] A target text vector acquisition submodule is used to perform entity extraction on the text vector through a pre-trained semantic acquisition model to obtain a target text vector, wherein the target text vector includes contextual semantic information of the conversation text;
[0090] The first text entity acquisition submodule is used to obtain multiple text entities by processing the target text vector.
[0091] In another embodiment of the present invention, the target normalized entity acquisition module 430 includes:
[0092] A second text entity acquisition submodule, used for inputting the target text vector and each of the text entities into a pre-trained entity screening model to obtain text entities in the affirmative sentence;
[0093] The target normalized entity acquisition submodule is used to take the normalized entity corresponding to the text entity in the affirmative sentence as the target normalized entity.
[0094] In another embodiment of the present invention, the apparatus further comprises:
[0095] The initial entity screening model training module is used to process the training text vector and the training text entity through the initial entity screening model to obtain the training entity screening result; obtain the second loss value according to the training entity screening result, the true label of the training entity screening result and the entity relevance loss value; when the second loss value meets the training condition, the training is completed, and the trained initial entity screening model is used as the entity screening model, wherein the entity relevance loss value is determined by the co-occurrence frequency of the training normalized entity corresponding to the training text entity and the candidate standard entity, and the candidate standard entity includes each standard entity in the standard entity library except the training normalized entity.
[0096] In another embodiment of the present invention, the apparatus further comprises:
[0097] The target reply text acquisition module is used to obtain the target reply text corresponding to the target entity according to the mapping relationship between each standard entity and the reply text.
[0098] The dialogue text processing device of the embodiment of the present invention obtains multiple text entities by performing entity extraction on the text vector of the dialogue text. Each text entity is normalized to obtain a normalized entity corresponding to each text entity. According to the text vector and each text entity, each normalized entity is screened based on the affirmative sentence to obtain the target normalized entity in the affirmative sentence. According to the target normalized entity, the target entity corresponding to the dialogue text is determined. The embodiment of the present invention realizes obtaining text entities according to text vectors, then normalizing the text entities to standardize the text entities, and then judging the normalized entities obtained by the normalization for affirmative sentences, and screening out the normalized entities in the affirmative sentences as the target entities of the dialogue text. Since the normalized entities in the negative sentences are eliminated, the target entity is more consistent with the text semantic information in the dialogue text, so that the target entity is more accurate.
[0099] The specific definition of the conversation text processing device can be found in the definition of the conversation text processing method above, which will not be repeated here. The various modules, submodules and units in the above-mentioned conversation text processing device can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules, submodules and units can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0100] It is worth noting that the various units, sub-modules and modules included in the above-mentioned device are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the protection scope of the embodiments of the present invention.
[0101] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 4 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the server side of a conversation text processing method.
[0102] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server through a network connection. When the computer program is executed by the processor, it implements the functions or steps of a client side of a conversation text processing method.
[0103] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the following steps when executing the computer program:
[0104] Perform entity extraction on the text vector of the conversation text to obtain multiple text entities;
[0105] Normalizing each of the text entities to obtain a normalized entity corresponding to each of the text entities;
[0106] According to the text vector and each of the text entities, each of the normalized entities is screened based on the affirmative sentence to obtain a target normalized entity in the affirmative sentence;
[0107] According to the target normalized entity, a target entity corresponding to the dialogue text is determined.
[0108] The computer device of the embodiment of the present invention can achieve entity extraction from the text vector of the dialogue text when the processor executes the computer program to obtain multiple text entities. Each text entity is normalized to obtain a normalized entity corresponding to each text entity. According to the text vector and each text entity, each normalized entity is screened based on the affirmative sentence to obtain the target normalized entity in the affirmative sentence. According to the target normalized entity, the target entity corresponding to the dialogue text is determined. The embodiment of the present invention achieves obtaining text entities according to text vectors, then normalizing the text entities to standardize the text entities, and then judging the normalized entities obtained by the normalization for affirmative sentences, and screening out the normalized entities in the affirmative sentences as the target entities of the dialogue text. The scheme of the embodiment of the present invention improves the accuracy of the target entities in the dialogue text.
[0109] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0110] Perform entity extraction on the text vector of the conversation text to obtain multiple text entities;
[0111] Normalizing each of the text entities to obtain a normalized entity corresponding to each of the text entities;
[0112] According to the text vector and each of the text entities, each of the normalized entities is screened based on the affirmative sentence to obtain a target normalized entity in the affirmative sentence;
[0113] According to the target normalized entity, a target entity corresponding to the dialogue text is determined.
[0114] The computer-readable storage medium of the embodiment of the present invention and the computer program executed by the processor can realize entity extraction from the text vector of the dialogue text to obtain multiple text entities. Each text entity is normalized to obtain a normalized entity corresponding to each text entity. According to the text vector and each text entity, each normalized entity is screened based on the affirmative sentence to obtain the target normalized entity in the affirmative sentence. According to the target normalized entity, the target entity corresponding to the dialogue text is determined. The embodiment of the present invention realizes obtaining text entities according to text vectors, then normalizing the text entities to standardize the text entities, and then judging the normalized entities obtained by the normalization process for affirmative sentences, and screening out the normalized entities in the affirmative sentences as the target entities of the dialogue text. The scheme of the embodiment of the present invention improves the accuracy of the target entities in the dialogue text.
[0115] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0116] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0117] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0118] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.
Claims
1. A method for processing a conversation text, characterized in that: include: Perform entity extraction on the text vector of the conversation text to obtain multiple text entities; Normalizing each of the text entities to obtain a normalized entity corresponding to each of the text entities; According to the text vector and each of the text entities, each of the normalized entities is screened based on the affirmative sentence to obtain a target normalized entity in the affirmative sentence; According to the target normalized entity, a target entity corresponding to the dialogue text is determined.
2. The method for processing a conversation text according to claim 1, characterized in that: The normalizing of each of the text entities to obtain a normalized entity corresponding to each of the text entities includes: By using a pre-trained normalization model, each preset standard entity and each of the text entities are matched to obtain a matching degree between each text entity and each standard entity; For each of the text entities, the standard entity with the highest matching degree is used as the normalized entity of the text entity.
3. The method for processing a conversation text according to claim 2, characterized in that: Before matching the preset standard entities and the text entities by the pre-trained normalization model to obtain the matching degree between each text entity and each standard entity, the method further includes: Through the initial model, each training sample pair is normalized to obtain a normalized processing result, wherein the training sample pair includes a training text entity, a positive sample of the training text entity, and a negative sample of the training text entity; Inputting the normalization processing result into the loss function to obtain a first loss value; When the first loss value does not satisfy a preset loss condition, adjusting the model parameters of the initial model and continuing training; When the first loss value satisfies the loss condition, the initial model is used as a normalized model.
4. The method for processing a conversation text according to claim 1, characterized in that: The text vector of the dialogue text is subjected to entity extraction to obtain multiple text entities, including: Performing entity extraction on the text vector through a pre-trained semantic acquisition model to obtain a target text vector, wherein the target text vector includes contextual semantic information of the conversation text; By processing the target text vector, multiple text entities are obtained.
5. The method for processing dialog text according to claim 4, characterized in that: The step of screening each of the normalized entities based on the affirmative sentence according to the text vector and each of the text entities to obtain a target normalized entity in the affirmative sentence includes: Inputting the target text vector and each of the text entities into a pre-trained entity screening model to obtain text entities in the affirmative sentence; The normalized entity corresponding to the text entity in the affirmative sentence is used as the target normalized entity.
6. The method for processing dialog text according to claim 5, characterized in that: Before inputting the target text vector and each of the text entities into a pre-trained entity screening model to obtain the text entities in the positive sentence, the method further includes: The training text vector and the training text entity are processed by the initial entity screening model to obtain the training entity screening result; A second loss value is obtained according to the training entity screening results, the true labels corresponding to the training entity screening results, and the entity relevance loss value. When the second loss value meets the training conditions, the training is completed, and the trained initial entity screening model is used as the entity screening model, wherein the entity relevance loss value is determined by the co-occurrence frequency between the training normalized entity corresponding to the training text entity and the candidate standard entity, and the candidate standard entity includes each standard entity in the standard entity library except the training normalized entity.
7. The method for processing a conversation text according to claim 1, characterized in that: After determining the target entity corresponding to the dialogue text according to the target normalized entity, the method further includes: According to the mapping relationship between each standard entity and the reply text, a target reply text corresponding to the target entity is obtained.
8. A conversation text processing device, characterized in that: include: A text entity acquisition module is used to extract entities from the text vector of the conversation text to obtain multiple text entities; A normalized entity acquisition module, used for normalizing each of the text entities to obtain a normalized entity corresponding to each of the text entities; A target normalized entity acquisition module, used to screen each of the normalized entities based on the affirmative sentence according to the text vector and each of the text entities, to obtain a target normalized entity in the affirmative sentence; A target entity determination module is used to determine a target entity corresponding to the dialogue text according to the target normalized entity.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the conversation text processing method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the conversation text processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Entity normalization method and device
CN110674264A
Voice text processing method and device based on dialogue system, equipment and medium
CN112395857A
Question and answer pair matching method and device, electronic equipment and storage medium
CN112417096A
Electronic apparatus and control method thereof
CN112970013A
Model generation method and device, entity recognition method and device, electronic equipment and storage medium
CN116187301A