Entity extraction method, device, apparatus and readable storage medium
By matching the semantic vectors of the current statement and the previous statement with the candidate entity information, the problem of entity extraction omission in multi-turn dialogue in the prior art is solved, realizing more accurate entity extraction and more intelligent interactive dialogue, and improving the performance of the interactive system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2021-04-21
- Publication Date
- 2026-05-22
Smart Images

Figure CN113761150B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an entity extraction method, apparatus, device, and readable storage medium. Background Technology
[0002] With the continuous development of computer technology, the application scope of online interactive systems is becoming increasingly wide. During the interaction between users and online interactive systems, accurately extracting the user's intended meaning is a crucial factor in ensuring effective interaction and providing useful information.
[0003] In related technologies, Natural Language Processing (NLP) is often used to extract entities from relatively specialized text content. When this extraction method is applied to dialogue text, it is only used to extract the content of one round of dialogue in order to obtain user intent.
[0004] In practical applications, user input is often informal language with strong colloquial expressions, and the expression of a single valid piece of information may be scattered across multiple turns of dialogue. Commonly used NLP methods are poorly adapted to natural language processing, and may miss information scattered across multiple turns of dialogue, resulting in poor accuracy and effectiveness of the obtained user intent information. Summary of the Invention
[0005] This application provides an entity extraction method, apparatus, device, and readable storage medium, the technical solution of which is as follows:
[0006] On one hand, embodiments of this application provide an entity extraction method, the method comprising:
[0007] Obtain a first semantic vector of the first statement currently input to the interactive system, a second semantic vector of the second statement generated before the first statement, and a third semantic vector of the candidate entity information, wherein the second statement includes at least one statement among the statement input to the interactive system before the first statement and the statement output by the interactive system;
[0008] Based on the first semantic vector and the third semantic vector, a first interaction vector between the first statement and the candidate entity information is obtained;
[0009] Based on the first semantic vector, the second semantic vector, and the third semantic vector, a second interaction vector between the second statement and the first statement, and a third interaction vector between the second statement and the candidate entity information are obtained.
[0010] Based on the first interaction vector, the second interaction vector, and the third interaction vector, a decision result is obtained, which is used to indicate whether the candidate entity information matches the first statement.
[0011] In response to the decision result indicating that the candidate entity information matches the first statement, the candidate entity information is used as the entity extraction result, and the entity extraction result is used to instruct the interactive system to conduct interactive dialogue.
[0012] On the other hand, a physical extraction device is provided, the device comprising:
[0013] The first acquisition module is used to acquire a first semantic vector of a first statement currently input to the interactive system, a second semantic vector of a second statement generated before the first statement, and a third semantic vector of candidate entity information. The second statement includes at least one statement among statements input to the interactive system before the first statement and statements output by the interactive system.
[0014] The second acquisition module is used to acquire a first interaction vector between the first statement and the candidate entity information based on the first semantic vector and the third semantic vector;
[0015] The third acquisition module is used to acquire, based on the first semantic vector, the second semantic vector and the third semantic vector, a second interaction vector between the second statement and the first statement and a third interaction vector between the second statement and the candidate entity information;
[0016] The matching module is used to obtain a decision result based on the first interaction vector, the second interaction vector, and the third interaction vector, wherein the decision result is used to indicate whether the candidate entity information matches the first statement;
[0017] The determination module is used to, in response to the decision result indicating that the candidate entity information matches the first statement, use the candidate entity information as the entity extraction result, and use the entity extraction result to instruct the interactive system to perform interactive dialogue.
[0018] In one possible implementation, the candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; the second acquisition module is used to acquire a single vector corresponding to the candidate entity information based on the first sub-vector and the second sub-vector; and to acquire the vector product of the single vector and the first semantic vector as the first interaction vector.
[0019] In one possible implementation, the candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; the third acquisition module is used to determine the second interaction vector based on the second semantic vector, the first sub-vector, and the first semantic vector; and to determine the third interaction vector based on the second semantic vector, the first sub-vector, the second sub-vector, and the first semantic vector.
[0020] In one possible implementation, the apparatus further includes a fourth acquisition module, configured to obtain a first similarity between the second statement and the first statement based on the second interaction vector; and to obtain a second similarity between the second statement and the candidate entity information based on the third interaction vector.
[0021] The matching module is used to calculate a decision value based on the first interaction vector, the second interaction vector, the third interaction vector, the first similarity, and the second similarity using a binary classification method.
[0022] In one possible implementation, the device further includes a selection module, configured to: obtain the text content of the next candidate entity information in response to the decision result indicating that the candidate entity information does not match the first statement; obtain a fourth semantic vector of the next candidate entity information based on the text content of the next candidate entity information; update the decision result based on the first semantic vector, the second semantic vector, and the fourth semantic vector; and use the next candidate entity information as the entity extraction result in response to the updated decision result indicating that the next candidate entity information matches the first statement.
[0023] In one possible implementation, a first acquisition module is configured to acquire the text content of the first statement, the text content of the second statement, and the text content of the candidate entity information; based on the text content of the first statement, acquire a first word vector of the first statement, and based on the first word vector, acquire a first semantic vector; based on the text content of the second statement, acquire a second word vector of the second statement, and based on the second word vector, acquire a second semantic vector; based on the text content of the candidate entity information, acquire a third word vector of the candidate entity information, and based on the third word vector, acquire a third semantic vector.
[0024] In one possible implementation, the first acquisition module is used to determine the word vector of each word in the text content of the first statement based on a pre-trained word vector set, thereby obtaining the first word vector; to concatenate the word vectors in the first word vector, and to perform a weighted summation on the concatenation results, thereby obtaining the model vector of the first statement; to obtain an intermediate layer vector based on the model vector; and to obtain the first semantic vector based on the intermediate layer vector.
[0025] On the other hand, a computer device is provided, the computer device including a processor and a memory, the memory storing at least one computer program, the at least one computer program being loaded and executed by the processor to implement any of the entity extraction methods described above.
[0026] On the other hand, a computer-readable storage medium is also provided, wherein at least one computer program is stored in the computer-readable storage medium, the at least one computer program being loaded and executed by a processor to implement any of the entity extraction methods described above.
[0027] On the other hand, a computer program product or computer program is also provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform any of the entity extraction methods described above.
[0028] The technical solution provided in this application has at least the following beneficial effects:
[0029] The entity extraction method provided in this application, based on the first statement of the current input interaction system and the second statement generated before the first statement, converts the obtained statements into semantic vector form and matches them with the semantic vector forms of candidate entities to obtain entity extraction results. This method's application of semantic vectors can more accurately describe the meaning of the statements, and its application of the second statement considers the impact of information from multi-turn dialogues on entity extraction, resulting in more accurate entity extraction results. This instructs the interaction system to conduct more intelligent and precise interactive dialogues, improving the interaction performance of the system. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a schematic diagram of the implementation environment of an entity extraction method provided in an embodiment of this application;
[0032] Figure 2 This is a flowchart of an entity extraction method provided in an embodiment of this application;
[0033] Figure 3 This is a schematic diagram of a dialogue text provided in an embodiment of this application;
[0034] Figure 4 This is a schematic diagram illustrating an embodiment of obtaining semantic vectors provided in this application;
[0035] Figure 5 This is a schematic diagram of the structure of an entity extraction model provided in an embodiment of this application;
[0036] Figure 6 This is a schematic diagram of an entity extraction device provided in an embodiment of this application;
[0037] Figure 7 This is a schematic diagram of another entity extraction device provided in the embodiments of this application;
[0038] Figure 8 This is a schematic diagram of the structure of a terminal provided in an embodiment of this application;
[0039] Figure 9 This is a schematic diagram of the structure of a server provided in an embodiment of this application. Detailed Implementation
[0040] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0041] With the continuous development of computer technology, the application scope of online interactive systems is becoming increasingly wide. During the interaction between users and the system, accurately extracting the user's intended meaning is crucial for ensuring effective interaction and providing useful information. To address this, this application provides an entity extraction method. Before introducing the entity extraction method provided in this application, some technical concepts will be explained to better understand the content of this application.
[0042] Medical Slot Filling: Used to extract attribute values for predefined slots from medical dialogues.
[0043] Bidirectional Encoder Representation from Transformers: This is a pre-trained language model whose word or sentence embeddings can help improve the performance of downstream natural language processing tasks.
[0044] A recurrent neural network (RNN) is a type of recurrent neural network that takes sequence data as input, recurses in the direction of sequence evolution, and connects all nodes (recurrent units) in a chain to form a closed loop.
[0045] Dialogue State Tracking (DST): Infers the current dialogue state St and user goal based on all dialogue history information.
[0046] See Figure 1 The diagram illustrates the implementation environment of the entity extraction method provided in this embodiment. This implementation environment includes a terminal 11 and a server 12.
[0047] The entity extraction method provided in this application can be applied to both terminal 11 and server 12, and this application does not limit it to either. For example, terminal 11 independently obtains a first statement and a second statement from the dialogue text content. The second statement includes at least one statement among those input to the interaction system before the first statement and those output by the interaction system. Terminal 11 performs entity extraction based on candidate entity information stored locally on the terminal or downloaded from server 12. For example, terminal 11 sends the obtained dialogue text content to server 12, and server 12 performs entity extraction based on the first statement, the second statement, and the candidate entity information stored in server 12. During the above process, terminal 11 and server 12 can transmit information.
[0048] In one possible implementation, terminal 11 can be a smart device such as a mobile phone, tablet computer, or personal computer. Server 12 can be a single server, a server cluster consisting of multiple servers, or a cloud computing service center. Terminal 11 and server 12 establish a communication connection via a wired or wireless network, which is not limited in this embodiment.
[0049] Those skilled in the art should understand that the above-described terminal 11 and server 12 are merely examples. Other existing or future terminals or servers that are applicable to this application should also be included within the scope of protection of this application, and are hereby incorporated by reference.
[0050] In an exemplary embodiment, the entity extraction method provided in this application embodiment can be implemented in a blockchain system. The candidate entity information involved in the entity extraction method provided in this application embodiment is stored on the blockchain in the blockchain system, and the system has high security and reliability.
[0051] based on Figure 1 For the implementation environment shown, see [link to implementation environment]. Figure 2 The present application provides an entity extraction method, which includes, but is not limited to, the following steps 201-205.
[0052] Step 201: Obtain the first semantic vector of the first statement currently input to the interactive system, the second semantic vector of the second statement generated before the first statement, and the third semantic vector of the candidate entity information. The second statement includes at least one of the statements input to the interactive system before the first statement and the statements output by the interactive system.
[0053] In interactive system applications, users input statements into the system, and the system outputs corresponding dialogue statements based on the content of the user's input. See also... Figure 3 This paper exemplifies a scenario where a user interacts with a system. During the interaction, the system extracts entities from the user's current input and previous dialogues, using the extracted entities to guide subsequent interactions.
[0054] The statement currently input to the interactive system is taken as the first statement, and the dialogue statements generated before the first statement are taken as the second statement. The second statement includes at least one of the statements input to the interactive system and statements output by the interactive system. For example, in this application, it is generally considered that the first statement has the closest semantic relationship with the previous statement, so only the statement preceding the first statement, i.e., the statement output by the interactive system, can be selected as the second statement.
[0055] Candidate entity information is information stored locally on the terminal or on a server for matching with the first statement. This application does not limit the method of obtaining candidate entity information. For example, candidate entity information may be set based on experience and professional knowledge according to the dialogue scenario corresponding to the interactive system. See, for example... Figure 3 The interactive system shown is based on Figure 3The dialogue content shown corresponds to candidate entity information related to medical terminology. In one possible implementation, candidate entity information includes an information name and an information value, represented as slot-value pairs in the form of [information name: information value], for example, [symptom: headache]. The same information name can correspond to different information values; for example, [symptom: headache], [symptom: nausea].
[0056] In one possible implementation, the process of obtaining the first semantic vector, the second semantic vector, and the third semantic vector in this step includes, but is not limited to, the following steps 2011-2014.
[0057] 2011: Obtain the text content of the first statement, the text content of the second statement, and the text content of the candidate entity information.
[0058] The embodiments of this application can be applied to interactive systems to extract entities based on the content of interactive dialogues; that is, the interactive system needs to obtain... Figure 3 The text content shown will be used for subsequent entity extraction operations.
[0059] In this scenario, the interactive system can provide users with various interactive dialogue methods such as text interaction or voice interaction. The process of obtaining the text content of the first statement includes: directly obtaining the text content formed by the user's input text information; or, obtaining the voice information generated based on the user's voice, recognizing the voice information using voice recognition technology, and obtaining the corresponding text content. The text content of candidate entity information can be directly obtained from the terminal's local storage or the server's storage space; this application embodiment does not limit this.
[0060] 2012: Based on the text content of the first sentence, obtain the first word vector of the first sentence, and based on the first word vector, obtain the first semantic vector.
[0061] To ensure the accuracy of entity extraction results, this application embodiment converts the first statement into a first semantic vector that can represent the semantics of the first statement. The process of obtaining the first semantic vector includes, but is not limited to, the following steps 1-4.
[0062] Step 1: Based on the pre-trained word vector set, determine the word vector of each word in the text content of the first sentence to obtain the first word vector.
[0063] After obtaining the text information of the first sentence, perform word segmentation on the first sentence to obtain at least one word in the first sentence; based on the pre-trained word vector set, determine the word vectors of each obtained word to obtain the first word vector. Exemplarily, the pre-trained word vector set can be the distributed Word2Vec or the Glove word vector, and these two types of word vectors can be pre-trained based on medical corpora using the Gensim external library. The specific form of the pre-trained word vector set is not limited in the embodiments of this application. In a possible implementation manner, the word vector can be obtained by random initialization.
[0064] See Figure 4 , an exemplary first sentence "I have a headache." is given. This first sentence includes 5 Chinese characters and 1 punctuation mark, a total of 6 words. After word segmentation, 6 words as shown in the word layer (Tokens) are obtained. Based on the pre-trained word vector set, determine the word vector corresponding to each word to obtain the first word vector as shown in the word vector layer. Figure 4 Figure 4
[0065] Step 2: Concatenate the word vectors in the first word vector, perform weighted summation on the concatenation result, and obtain the model vector of the first sentence.
[0066] In a possible implementation manner, assume indicates that a first sentence contains words , and each word is represented by the corresponding word vector.
[0067] Suppose represents the concatenation of words starting from index words. Then, referring to Formula 1, calculate the value of the vector concatenation result , where represents vector concatenation:
[0068]
[0069] Exemplarily, see Figure 4 , taking the first sentence "I have a headache." as an example, this first sentence includes 6 words. Set i = 2 and n = 3, then represents calculating the concatenation of the vectors of 3 words from the second word (the character "have") to the fourth word (the character "head"). Similarly, we can perform corresponding calculations starting from any word.
[0070] Based on the above , according to Formula 2, calculate the cumulative model vector, and the obtained model vector represents the n-gram (Chinese language model) model of the first sentence, which represents the weighted sum of the word vectors in the first sentence.
[0071]
[0072] Exemplarily, refer to Figure 4 the given embodiments , taking n = 2 as an example, the binary vector connection corresponding model vector is obtained as follows:
[0073]
[0074] In this step, the connection results of any number of words connected can be calculated. In the embodiments of the present application, according to Formula 1, calculate the connection results of binary vector connections and ternary vector connections; respectively based on the connection results of binary vector connections and ternary vector connections, calculate the model vectors corresponding to binary vector connections and the model vectors corresponding to ternary vector connections . The model vector corresponding to the unitary vector without vector connection is also calculated . Refer to Figure 4 the representation form of the model vector layer in
[0075] Exemplarily, taking the example of obtaining the model vector corresponding to the ternary vector connection, based on Formula 1, set i = 1, n = 3, then obtain the connection of the vectors of the three words from the first word (the character "I") to the third word (the character "point"): . According to the same theory, obtain the remaining , , . Based on Formula 2, the model vector of the ternary vector connection is calculated as:
[0076]
[0077] Step 3: Obtain the intermediate layer vector based on the model vector.
[0078] In this step, each model vector is mapped to an intermediate layer vector representation of the same size through a non-linear function represented by Formula 3:
[0079]
[0080] In the above Formula 3, represents the weight parameter, Let S represent the bias parameters, σ represent the activation function (sigmoid), and S represent a separate set of parameters reserved for each candidate entity. That is, the weight parameters and bias parameters corresponding to each candidate entity are different, and S is used to identify the candidate entity. Equation 3 maps the n-gram model vectors to the same vector dimension.
[0081] See Figure 4 In an exemplary embodiment, the obtained model vector Substitute into Formula 3 to obtain the corresponding intermediate layer vectors. , , Among them, the intermediate layer vector , , The vectors have the same dimension.
[0082] Step 4: Obtain the first semantic vector based on the intermediate layer vector.
[0083] In this step, the sum of the three intermediate layers is calculated to obtain the first semantic vector.
[0084]
[0085] In one possible implementation, the method, during vector processing, identifies the parts of the sentence associated with the information being retrieved, ignoring verbs, modal particles, or stop indicators. For example, during the calculation process, the weights corresponding to modal particles, verbs, and other similar information are reduced.
[0086] 2013: Based on the text content of the second statement, obtain the second word vector of the second statement, and based on the second word vector, obtain the second semantic vector.
[0087] In one possible implementation, the process of this step is the same as that of obtaining the first word vector in step 2012, and will not be described again in this embodiment. For example, the second semantic vector can be represented as... .
[0088] 2014: Based on the text content of candidate entity information, obtain the third word vector of candidate entity information, and based on the third word vector, obtain the third semantic vector.
[0089] In one possible implementation, candidate entity information includes an information name and an information value. Based on a pre-trained word vector set, the word vectors of each word in the text content of the candidate entity information are determined, resulting in a third word vector. Based on the third word vector, a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value are obtained. Where the information name and information value consist of multiple characters, the sum of the word vectors is calculated separately to obtain the first and second sub-vectors.
[0090] Exemplarily, the candidate entity information is [symptom: headache]. The word vectors of 5 words in the candidate entity are respectively obtained, and the sum of the word vectors of the two words "symptom" and "condition" is calculated to obtain the first sub-vector. ; Calculate the sum of the word vectors of the two words "head" and "ache" to obtain the second sub-vector. .
[0091] In a possible implementation manner, the present application does not limit the execution order of steps 2012 - step 2014.
[0092] Step 202: Based on the first semantic vector and the third semantic vector, obtain the first interaction vector between the first statement and the candidate entity information.
[0093] In a possible implementation manner, the candidate entity information includes an information name and an information value, and is represented in the form of a slot value pair, and the representation form is [information name: information value]. The third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value. Then the execution process of this step includes:
[0094] Obtain a single vector corresponding to the candidate entity information based on the first sub-vector and the second sub-vector; obtain the vector product of the single vector and the first semantic vector as the first interaction vector.
[0095] In an exemplary embodiment, the first sub-vector corresponding to the information name is represented as , and the second sub-vector corresponding to the information value is represented as . Based on the first sub-vector and the second sub-vector, refer to formula 5 to obtain the single vector corresponding to the candidate entity information.
[0096]
[0097] Based on formula 6, calculate the vector product of the single vector of the candidate entity information and the first semantic vector of the first statement, and use the calculation result as the first interaction vector.
[0098] To a certain extent, the first interaction vector can be used to determine whether a statement matches the candidate entity information, and the first interaction vector reduces a rich feature set to a scalar.
[0099]
[0100] Step 203: Based on the first semantic vector, the second semantic vector and the third semantic vector, obtain the second interaction vector between the second statement and the first statement and the third interaction vector between the second statement and the candidate entity information.
[0101] The execution process of this step includes: determining the second interaction vector based on the second semantic vector, the first sub-vector, and the first semantic vector; and determining the third interaction vector based on the second semantic vector, the first sub-vector, the second sub-vector, and the first semantic vector.
[0102] In one possible implementation, the first sub-vector is applied based on Equation 7. Second semantic vector and the first semantic vector The second interaction vector is calculated. Based on Formula 8, the first sub-vector is applied. The second subvector Second semantic vector and the first semantic vector The third interaction vector is calculated. .
[0103]
[0104]
[0105] In one possible implementation, the execution order of steps 202 and 203 is not limited. For example, steps 202 and 203 can be performed in parallel, or step 203 can be executed first, followed by step 202.
[0106] Step 204: Based on the first interaction vector, the second interaction vector, and the third interaction vector, obtain the decision result, which is used to indicate whether the candidate entity information matches the first statement.
[0107] In one possible implementation, after step 203, a first similarity between the second statement and the first statement is obtained based on the second interaction vector; and a second similarity between the second statement and the candidate entity information is obtained based on the third interaction vector.
[0108] For example, the first similarity Second similarity The calculation is based on the following formulas 9 and 10, where, This is a logistic regression model.
[0109]
[0110]
[0111] In this step, the decision result is obtained based on the first interaction vector, the second interaction vector, and the third interaction vector. This includes calculating the decision result using a binary classification method based on the first interaction vector, the second interaction vector, the third interaction vector, the first similarity, and the second similarity.
[0112] In one possible implementation, based on Formula 11, the first interaction vector, the second interaction vector, the third interaction vector, the first similarity, and the second similarity are substituted into the corresponding positions to calculate the decision result of the binary classification decision.
[0113]
[0114] here Represents a nonlinear implicit function. This represents the Sigmoid function, which can be used as a binary classification decision machine. In one possible implementation, the output y is a value between [0,1]. In another possible implementation, the output y is either 1 or 0.
[0115] Step 205: In response to the decision result indicating that the candidate entity information matches the first statement, the candidate entity information is used as the entity extraction result, which is used to instruct the interactive system to conduct interactive dialogue.
[0116] In one possible implementation, the decision result is compared with a reference condition. When the decision result meets the reference condition, the decision result indicates that the candidate entity information matches the first statement, and the candidate entity information is used as the entity extraction result. For example, in a scenario where the output y is a value between [0,1], the reference condition is set as a threshold. Meeting the reference condition means that the value of the output decision result is higher than the threshold. For example, if the threshold is set to 0.5, and the y value is 0.7, then the decision result is considered to indicate that the candidate entity information matches the first statement, and the candidate entity information is used as the entity extraction result.
[0117] Optionally, when y is 1 or 0, 1 can be set to indicate that the decision result indicates that the candidate entity information matches the first statement, and 0 can indicate that the decision result indicates that the candidate entity information does not match the first statement; of course, 1 and 0 can also be set to have opposite meanings.
[0118] In one possible implementation, after step 204, the following steps may also be performed:
[0119] In response to the decision result indicating that the candidate entity information does not match the first statement, the text content of the next candidate entity information is obtained; based on the text content of the next candidate entity information, the fourth semantic vector of the next candidate entity information is obtained; based on the first semantic vector, the second semantic vector, and the fourth semantic vector, the decision result is updated; in response to the updated decision result indicating that the next candidate entity information matches the first statement, the next candidate entity information is used as the entity extraction result.
[0120] The execution method of each step can be found in steps 201-205 above. This application will not repeat it here.
[0121] In one possible implementation, see Figure 5 A schematic diagram of the structure of an exemplary entity extraction model is given. Steps 201-203 are executed in the word embedding layer and the interaction layer, where step 1 in step 2012 is executed in the word embedding layer; steps 204-205 are executed in the decision layer.
[0122] The entity extraction method provided in this application, based on the first statement of the current input interaction system and the second statement generated before the first statement, converts the obtained statements into semantic vector form and matches them with the semantic vector forms of candidate entities to obtain entity extraction results. This method's application of semantic vectors can more accurately describe the meaning of the statements, and its application of the second statement considers the impact of information from multi-turn dialogues on entity extraction, resulting in more accurate entity extraction results. This instructs the interaction system to conduct more intelligent and precise interactive dialogues, improving the interaction performance of the system.
[0123] In the exemplary embodiment, the accuracy of the above entity extraction method was tested. In the exemplary embodiment, the history window size was selected as 1, that is, only the sentence preceding the current first sentence was selected as the second sentence. In one possible implementation, the size of this value is not limited, and multiple sentences can be selected for testing to improve the accuracy of the above method.
[0124] In this embodiment, the number of epochs was set to 100, the batch size to 128, the learning rate to 0.01, and the word vector dimension to 300. The experimental results are shown in Table 1 below. The F1 score in the table is the harmonic mean calculated based on precision and recall, which can reflect the effectiveness of this method to a certain extent.
[0125] Table 1
[0126]
[0127] Based on the data in the table above, it can be seen that the accuracy of the extraction results obtained by the method provided in this application embodiment is above 89%, which proves that the entity extraction results of the method provided in this application embodiment have high accuracy.
[0128] In an exemplary embodiment, the experimental results of three different word vector representation methods were also statistically analyzed, with the distributed Word2Vec and GloVe word vectors having a dimension of 300.
[0129] As shown in Table 2, using pre-trained word vector sets Word2Vec and GloVe can improve the entity extraction performance of interactive systems to some extent.
[0130] Table 2
[0131]
[0132] Based on the above exemplary embodiments, it can be seen that the application of semantic vectors in this method can more accurately describe the meaning of the statement. The application of the second statement takes into account the impact of information in multi-turn dialogue on entity extraction, which can obtain more accurate entity extraction results, instruct the interactive system to conduct more intelligent and precise interactive dialogue, and improve the interactive performance of the interactive system.
[0133] See Figure 6 This application provides an entity extraction device, which includes, but is not limited to, the following modules:
[0134] The first acquisition module 601 is used to acquire the first semantic vector of the first statement currently input to the interactive system, the second semantic vector of the second statement generated before the first statement, and the third semantic vector of the candidate entity information. The second statement includes at least one statement among the statement input to the interactive system before the first statement and the statement output by the interactive system.
[0135] The second acquisition module 602 is used to acquire a first interaction vector between the first statement and the candidate entity information based on the first semantic vector and the third semantic vector.
[0136] The third acquisition module 603 is used to acquire, based on the first semantic vector, the second semantic vector and the third semantic vector, the second interaction vector between the second statement and the first statement and the third interaction vector between the second statement and the candidate entity information;
[0137] The matching module 604 is used to obtain a decision result based on the first interaction vector, the second interaction vector and the third interaction vector. The decision result is used to indicate whether the candidate entity information matches the first statement.
[0138] The determination module 605 is used to respond to the decision result indicating that the candidate entity information matches the first statement, and to use the candidate entity information as the entity extraction result. The entity extraction result is used to instruct the interactive system to conduct interactive dialogue.
[0139] In one possible implementation, the candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; the second acquisition module 602 is used to acquire a single vector corresponding to the candidate entity information based on the first sub-vector and the second sub-vector; and to acquire the vector product of the single vector and the first semantic vector as the first interaction vector.
[0140] In one possible implementation, the candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; the third acquisition module 603 is used to determine a second interaction vector based on the second semantic vector, the first sub-vector, and the first semantic vector; and to determine a third interaction vector based on the second semantic vector, the first sub-vector, the second sub-vector, and the first semantic vector.
[0141] See Figure 7 In one possible implementation, the apparatus further includes a fourth acquisition module 606, used to obtain a first similarity between the second statement and the first statement based on a second interaction vector; and to obtain a second similarity between the second statement and candidate entity information based on a third interaction vector.
[0142] The matching module 604 is used to calculate the decision value based on the first interaction vector, the second interaction vector, the third interaction vector, the first similarity, and the second similarity using a binary classification method.
[0143] See Figure 7 In one possible implementation, the device further includes a selection module 607, configured to: obtain the text content of the next candidate entity information in response to a decision result indicating that the candidate entity information does not match the first statement; obtain the fourth semantic vector of the next candidate entity information based on the text content of the next candidate entity information; update the decision result based on the first semantic vector, the second semantic vector, and the fourth semantic vector; and use the next candidate entity information as the entity extraction result in response to a decision result indicating that the next candidate entity information matches the first statement.
[0144] In one possible implementation, the first acquisition module 601 is used to acquire the text content of the first statement, the text content of the second statement, and the text content of the candidate entity information; based on the text content of the first statement, acquire the first word vector of the first statement, and based on the first word vector, acquire the first semantic vector; based on the text content of the second statement, acquire the second word vector of the second statement, and based on the second word vector, acquire the second semantic vector; based on the text content of the candidate entity information, acquire the third word vector of the candidate entity information, and based on the third word vector, acquire the third semantic vector.
[0145] In one possible implementation, the first acquisition module 601 is used to determine the word vector of each word in the text content of the first sentence based on the pre-trained word vector set, and obtain the first word vector; to connect the word vectors in the first word vector, and to perform a weighted summation on the connection results to obtain the model vector of the first sentence; to obtain the intermediate layer vector based on the model vector; and to obtain the first semantic vector based on the intermediate layer vector.
[0146] Figure 8 This is a schematic diagram of the structure of a terminal 800 provided in an embodiment of this application. The terminal 800 can be a smartphone, tablet computer, laptop computer, or desktop computer. The terminal may also be referred to as user equipment, portable terminal, laptop terminal, desktop terminal, or other names.
[0147] Typically, terminal 800 includes a processor 801 and a memory 802.
[0148] Processor 801 may include one or more processing cores, such as a 4-core processor or an 8-core processor. Processor 801 may be implemented using at least one of the following hardware forms: DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), or PLA (Programmable Logic Array). Processor 801 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state.
[0149] The memory 802 may include one or more computer-readable storage media, which may be non-transitory. The memory 802 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 802 are used to store at least one instruction, which is executed by the processor 801 to implement the entity extraction method provided in the method embodiments of this application.
[0150] In some embodiments, the terminal may also optionally include: a peripheral device interface 803 and at least one peripheral device. The processor 801, memory 802, and peripheral device interface 803 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 803 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of: a radio frequency circuit 804, a display screen 805, a camera assembly 806, an audio circuit 807, and a power supply 809.
[0151] Peripheral device interface 803 can be used to connect at least one I / O (Input / Output) related peripheral device to processor 801 and memory 802. In some embodiments, processor 801, memory 802 and peripheral device interface 803 are integrated on the same chip or circuit board; in some other embodiments, any one or two of processor 801, memory 802 and peripheral device interface 803 can be implemented on separate chips or circuit boards, which is not limited in this embodiment.
[0152] The radio frequency (RF) circuit 804 is used to receive and transmit RF (Radio Frequency) signals, also known as electromagnetic signals. The RF circuit 804 communicates with communication networks and other communication devices via electromagnetic signals. The RF circuit 804 converts electrical signals into electromagnetic signals for transmission, or converts received electromagnetic signals back into electrical signals. Optionally, the RF circuit 804 includes: an antenna system, an RF transceiver, one or more amplifiers, a tuner, an oscillator, a digital signal processor, a codec chipset, a user identity module card, etc. The RF circuit 804 can communicate with other terminals through at least one wireless communication protocol. This wireless communication protocol includes, but is not limited to: metropolitan area networks (MANs), various generations of mobile communication networks (2G, 3G, 4G, and 5G), wireless local area networks (WLANs), and / or WiFi (Wireless Fidelity) networks. In some embodiments, the RF circuit 804 may also include circuitry related to NFC (Near Field Communication), which is not limited in this application.
[0153] Display screen 805 is used to display a UI (User Interface). This UI may include graphics, text, icons, videos, and any combination thereof. When display screen 805 is a touch display screen, it also has the ability to collect touch signals on or above its surface. These touch signals can be input as control signals to processor 801 for processing. In this case, display screen 805 can also be used to provide virtual buttons and / or a virtual keyboard, also known as soft buttons and / or a soft keyboard. In some embodiments, there may be one display screen 805, located on the front panel of the terminal; in other embodiments, there may be at least two display screens, respectively located on different surfaces of the terminal or in a folded design; in still other embodiments, display screen 805 may be a flexible display screen, located on a curved or folded surface of the terminal. Furthermore, display screen 805 may be configured as a non-rectangular, irregular shape, i.e., a non-rectangular screen. Display screen 805 may be made of materials such as LCD (Liquid Crystal Display) or OLED (Organic Light-Emitting Diode).
[0154] The camera assembly 806 is used to acquire images or videos. Optionally, the camera assembly 806 includes a front-facing camera and a rear-facing camera. Typically, the front-facing camera is located on the front panel of the terminal, and the rear-facing camera is located on the back of the terminal. In some embodiments, there are at least two rear-facing cameras, which are any one of a main camera, a depth-sensing camera, a wide-angle camera, and a telephoto camera, to achieve background blurring by fusion of the main camera and the depth-sensing camera, panoramic shooting by fusion of the main camera and the wide-angle camera, VR (Virtual Reality) shooting, or other fusion shooting functions. In some embodiments, the camera assembly 806 may also include a flash. The flash can be a single-color temperature flash or a dual-color temperature flash. A dual-color temperature flash refers to a combination of a warm-light flash and a cool-light flash, which can be used for light compensation at different color temperatures.
[0155] The audio circuit 807 may include a microphone and a speaker. The microphone is used to collect sound waves from the user and the environment, converting the sound waves into electrical signals that are input to the processor 801 for processing, or input to the radio frequency circuit 804 for voice communication. For stereo sound acquisition or noise reduction purposes, multiple microphones may be used, each positioned at a different location on the terminal. The microphone may also be an array microphone or an omnidirectional microphone. The speaker is used to convert the electrical signals from the processor 801 or the radio frequency circuit 804 into sound waves. The speaker may be a conventional diaphragm speaker or a piezoelectric ceramic speaker. When the speaker is a piezoelectric ceramic speaker, it can convert electrical signals not only into audible sound waves but also into inaudible sound waves for purposes such as distance measurement. In some embodiments, the audio circuit 807 may also include a headphone jack.
[0156] Power supply 809 is used to power the various components in the terminal. Power supply 809 can be AC power, DC power, a disposable battery, or a rechargeable battery. When power supply 809 includes a rechargeable battery, the rechargeable battery can support wired or wireless charging. The rechargeable battery can also be used to support fast charging technology.
[0157] In some embodiments, the terminal further includes one or more sensors 810. The one or more sensors 810 include, but are not limited to: an acceleration sensor 811, a gyroscope sensor 812, a pressure sensor 813, an optical sensor 815, and a proximity sensor 816.
[0158] Accelerometer 811 can detect the magnitude of acceleration along the three coordinate axes of a coordinate system established by the terminal. For example, accelerometer 811 can be used to detect the components of gravitational acceleration along the three coordinate axes. Processor 801 can control display screen 805 to display the user interface in either a landscape or portrait view based on the gravitational acceleration signal acquired by accelerometer 811. Accelerometer 811 can also be used for games or for acquiring user motion data.
[0159] The gyroscope sensor 812 can detect the terminal's orientation and rotation angle. The gyroscope sensor 812, in conjunction with the accelerometer sensor 811, can collect the user's 3D movements on the terminal. Based on the data collected by the gyroscope sensor 812, the processor 801 can perform the following functions: motion sensing (e.g., changing the UI based on the user's tilt), image stabilization during shooting, game control, and inertial navigation.
[0160] The pressure sensor 813 can be disposed on the side bezel of the terminal and / or on the lower layer of the display screen 805. When the pressure sensor 813 is disposed on the side bezel of the terminal, it can detect the user's grip signal on the terminal, and the processor 801 can perform left / right hand recognition or quick operation based on the grip signal collected by the pressure sensor 813. When the pressure sensor 813 is disposed on the lower layer of the display screen 805, the processor 801 can control the operable controls on the UI interface based on the user's pressure operation on the display screen 805. The operable controls include at least one of button controls, scroll bar controls, icon controls, and menu controls.
[0161] An optical sensor 815 is used to collect ambient light intensity. In one embodiment, the processor 801 can control the display brightness of the display screen 805 based on the ambient light intensity collected by the optical sensor 815. Specifically, when the ambient light intensity is high, the display brightness of the display screen 805 is increased; when the ambient light intensity is low, the display brightness of the display screen 805 is decreased. In another embodiment, the processor 801 can also dynamically adjust the shooting parameters of the camera assembly 806 based on the ambient light intensity collected by the optical sensor 815.
[0162] The proximity sensor 816, also known as a distance sensor, is typically installed on the front panel of the terminal. The proximity sensor 816 is used to detect the distance between the user and the front of the terminal. In one embodiment, when the proximity sensor 816 detects that the distance between the user and the front of the terminal is gradually decreasing, the processor 801 controls the display screen 805 to switch from a screen-on state to a screen-off state; when the proximity sensor 816 detects that the distance between the user and the front of the terminal is gradually increasing, the processor 801 controls the display screen 805 to switch from a screen-off state to a screen-on state.
[0163] Those skilled in the art will understand that Figure 8 The structure shown does not constitute a limitation on the terminal and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0164] Figure 9This is a schematic diagram of a server structure provided in an embodiment of this application. The server can vary significantly due to differences in configuration or performance. It may include one or more Central Processing Units (CPUs) 901 and one or more memories 902. The one or more memories 902 store at least one computer program, which is loaded and executed by the one or more processors 901 to implement the entity extraction methods provided in the various method embodiments described above. Of course, the server may also have wired or wireless network interfaces, a keyboard, and input / output interfaces for input and output. The server may also include other components for implementing device functions, which will not be elaborated upon here.
[0165] In an exemplary embodiment, a computer device is also provided, comprising a processor and storage, wherein at least one computer program is stored in the storage. The at least one computer program is loaded and executed by one or more processors to implement any of the entity extraction methods described above.
[0166] In an exemplary embodiment, a computer-readable storage medium is also provided, which stores at least one computer program that is loaded and executed by a processor of a computer device to implement any of the entity extraction methods described above.
[0167] In one possible implementation, the aforementioned computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0168] In an exemplary embodiment, a computer program product or computer program is also provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform any of the entity extraction methods described above.
[0169] In exemplary embodiments, the computer program involved in the embodiments of this application can be deployed and executed on a single computer device, or on multiple computer devices located in one location, or on multiple computer devices distributed across multiple locations and interconnected via a communication network. These multiple computer devices distributed across multiple locations and interconnected via a communication network can constitute a blockchain system. That is, both the aforementioned server and terminal can serve as node devices in the blockchain system.
[0170] It should be noted that the terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the above exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0171] It should be understood that "multiple" as used in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0172] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. An entity extraction method, characterized in that, The method includes: Obtain a first semantic vector of the first statement currently input to the interactive system, a second semantic vector of the second statement generated before the first statement, and a third semantic vector of the candidate entity information, wherein the second statement includes at least one statement among the statement input to the interactive system before the first statement and the statement output by the interactive system; Based on the first semantic vector and the third semantic vector, a first interaction vector between the first statement and the candidate entity information is obtained; Based on the first semantic vector, the second semantic vector, and the third semantic vector, a second interaction vector between the second statement and the first statement, and a third interaction vector between the second statement and the candidate entity information are obtained. Based on the second interaction vector, the first similarity between the second statement and the first statement is obtained; Based on the third interaction vector, a second similarity between the second statement and the candidate entity information is obtained; Based on the first interaction vector, the second interaction vector, the third interaction vector, the first similarity, and the second similarity, a binary classification method is used to calculate and obtain a decision result. The decision result is used to indicate whether the candidate entity information matches the first statement. In response to the decision result indicating that the candidate entity information matches the first statement, the candidate entity information is used as the entity extraction result, and the entity extraction result is used to instruct the interactive system to conduct interactive dialogue.
2. The method according to claim 1, characterized in that, The candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; The step of obtaining the first interaction vector between the first statement and the candidate entity information based on the first semantic vector and the third semantic vector includes: Based on the first sub-vector and the second sub-vector, obtain a single vector corresponding to the candidate entity information; The vector product of the single vector and the first semantic vector is obtained as the first interaction vector.
3. The method according to claim 1, characterized in that, The candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; The step of obtaining a second interaction vector between the second statement and the first statement, and a third interaction vector between the second statement and the candidate entity information, based on the first semantic vector, the second semantic vector, and the third semantic vector, includes: The second interaction vector is determined based on the second semantic vector, the first sub-vector, and the first semantic vector. The third interaction vector is determined based on the second semantic vector, the first sub-vector, the second sub-vector, and the first semantic vector.
4. The method according to any one of claims 1-3, characterized in that, After calculating the decision result using a binary classification method based on the first interaction vector, the second interaction vector, the third interaction vector, the first similarity, and the second similarity, the method further includes: In response to the decision result indicating that the candidate entity information does not match the first statement, the text content of the next candidate entity information is obtained; Based on the text content of the next candidate entity information, obtain the fourth semantic vector of the next candidate entity information; The decision result is updated based on the first semantic vector, the second semantic vector, and the fourth semantic vector. In response to the updated decision result indicating that the next candidate entity information matches the first statement, the next candidate entity information is used as the entity extraction result.
5. The method according to claim 1, characterized in that, The process of obtaining the first semantic vector of the first statement currently input to the interactive system, the second semantic vector of the second statement generated before the first statement, and the third semantic vector of the candidate entity information includes: Obtain the text content of the first statement, the text content of the second statement, and the text content of the candidate entity information; Based on the text content of the first statement, obtain the first word vector of the first statement, and based on the first word vector, obtain the first semantic vector; Based on the text content of the second statement, obtain the second word vector of the second statement, and based on the second word vector, obtain the second semantic vector; Based on the text content of the candidate entity information, the third word vector of the candidate entity information is obtained, and based on the third word vector, the third semantic vector is obtained.
6. The method according to claim 5, characterized in that, The step of obtaining the first word vector of the first statement based on its text content, and obtaining the first semantic vector based on the first word vector, includes: Based on the pre-trained word vector set, the word vector of each word in the text content of the first statement is determined, and the first word vector is obtained; The word vectors in the first word vector are concatenated, and the concatenation results are weighted and summed to obtain the model vector of the first sentence; Based on the model vectors, the intermediate layer vectors are obtained; Based on the intermediate layer vector, the first semantic vector is obtained.
7. A physical extraction device, characterized in that, The device includes: The first acquisition module is used to acquire a first semantic vector of a first statement currently input to the interactive system, a second semantic vector of a second statement generated before the first statement, and a third semantic vector of candidate entity information. The second statement includes at least one statement among statements input to the interactive system before the first statement and statements output by the interactive system. The second acquisition module is used to acquire a first interaction vector between the first statement and the candidate entity information based on the first semantic vector and the third semantic vector; The third acquisition module is used to acquire, based on the first semantic vector, the second semantic vector and the third semantic vector, a second interaction vector between the second statement and the first statement and a third interaction vector between the second statement and the candidate entity information; The fourth acquisition module is used to obtain a first similarity between the second statement and the first statement based on the second interaction vector; and to obtain a second similarity between the second statement and the candidate entity information based on the third interaction vector. The matching module is used to calculate a decision result based on the first interaction vector, the second interaction vector, the third interaction vector, the first similarity, and the second similarity using a binary classification method. The decision result is used to indicate whether the candidate entity information matches the first statement. The determination module is used to, in response to the decision result indicating that the candidate entity information matches the first statement, use the candidate entity information as the entity extraction result, and use the entity extraction result to instruct the interactive system to perform interactive dialogue.
8. The apparatus according to claim 7, characterized in that, The candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; The second acquisition module is used to acquire a single vector corresponding to the candidate entity information based on the first sub-vector and the second sub-vector; The vector product of the single vector and the first semantic vector is obtained as the first interaction vector.
9. The apparatus according to claim 7, characterized in that, The candidate entity information includes an information name and an information value, and the third semantic vector includes a first sub-vector corresponding to the information name and a second sub-vector corresponding to the information value; The third acquisition module is used to determine the second interaction vector based on the second semantic vector, the first sub-vector, and the first semantic vector; and to determine the third interaction vector based on the second semantic vector, the first sub-vector, the second sub-vector, and the first semantic vector.
10. The apparatus according to any one of claims 7-9, characterized in that, The device further includes: The selection module is configured to, in response to the decision result indicating that the candidate entity information does not match the first statement, obtain the text content of the next candidate entity information; obtain the fourth semantic vector of the next candidate entity information based on the text content of the next candidate entity information; update the decision result based on the first semantic vector, the second semantic vector, and the fourth semantic vector; and, in response to the updated decision result indicating that the next candidate entity information matches the first statement, use the next candidate entity information as the entity extraction result.
11. The apparatus according to claim 7, characterized in that, The first acquisition module is configured to acquire the text content of the first statement, the text content of the second statement, and the text content of the candidate entity information; based on the text content of the first statement, acquire the first word vector of the first statement, and based on the first word vector, acquire the first semantic vector; based on the text content of the second statement, acquire the second word vector of the second statement, and based on the second word vector, acquire the second semantic vector; based on the text content of the candidate entity information, acquire the third word vector of the candidate entity information, and based on the third word vector, acquire the third semantic vector.
12. The apparatus according to claim 11, characterized in that, The first acquisition module is used to determine the word vector of each word in the text content of the first statement based on the pre-trained word vector set, and obtain the first word vector; to connect the word vectors in the first word vector, and to perform a weighted summation on the connection results to obtain the model vector of the first statement; and to obtain the intermediate layer vector based on the model vector. Based on the intermediate layer vector, the first semantic vector is obtained.
13. A computer device comprising a processor and a memory, the memory storing at least one computer program or instruction, the at least one computer program or instruction being loaded and executed by the processor to enable the computer device to implement the entity extraction method according to any one of claims 1-6.
14. A computer-readable storage medium storing at least one computer program or instruction, said at least one computer program or instruction being loaded and executed by a processor to enable a computer to implement the entity extraction method according to any one of claims 1-6.
15. A computer program product comprising computer instructions stored in a computer-readable storage medium, wherein a processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions such that the computer device performs the entity extraction method of any one of claims 1-6.