Text matching method, device, equipment and storage medium
The text summary model trained by BERT model and MLP is used to de-colloquialize the text of the question and answer system, extract summary data and perform similarity calculation, which solves the problem of low text matching accuracy in the question and answer system and improves the feedback effect of the question and answer system. .
Patent Information
- Application Number
- CN202110667338.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-16
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-06-16
AI Technical Summary
The existing question and answer system is based on keyword matching and cannot effectively match texts with different word expressions but the same semantics, resulting in low text matching accuracy and poor feedback from the question and answer system.
The text summary model trained using the BERT model and multi-layer perceptron (MLP) de-colloquially processes the matched text, extracts the summary data of the text, and determines the matching result from the text database through text vector similarity calculation.
The accuracy of text matching is improved, the semantic information of text data can be understood more accurately, and the feedback effect of the question and answer system is enhanced.
Smart Images

Figure CN113297353B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence, and in particular to a text matching method, apparatus, device and storage medium. Background Art
[0002] The main implementation of the intelligent question-answering system includes two parts: text matching and answer extraction. Among them, text matching is an important part of the intelligent question-answering system, which is used to match the standard document paragraphs corresponding to the questions input by the user.
[0003] The current text matching scheme is mainly based on keyword matching standard documents, which can only match texts that are exactly the same as their description content, and cannot match texts expressed in different words but with the same semantics. The accuracy of text matching is low, resulting in poor feedback effect of the question and answer system. Summary of the invention
[0004] The main purpose of the present disclosure is to provide a text matching method, apparatus, device and storage medium for improving the accuracy of text matching to enhance the feedback effect of a question-and-answer system.
[0005] In order to achieve the above objectives, in a first aspect, the present disclosure provides a text matching method, comprising:
[0006] Acquire first text data to be matched;
[0007] The first text data is de-colloquialized by using a text summary model to obtain the second text data, where the second text data is summary data of the first text data, and the text summary model is obtained by training with a BERT model and a multi-layer perceptron MLP;
[0008] A text matching result of the first text data is determined from a text database according to the second text data.
[0009] In an optional embodiment of the present disclosure, performing de-colloquialization processing on the first text data by using the text summarization model to obtain the second text data includes:
[0010] Performing character-level segmentation on the first text data to obtain segmented first text data;
[0011] Converting the segmented first text data into a digital sequence according to a preset dictionary;
[0012] The digital sequence is input into the text summary model to obtain the second text data.
[0013] In an optional embodiment of the present disclosure, the step of inputting the digital sequence into the text summary model to obtain the second text data includes:
[0014] Inputting the digital sequence into the BERT model of the text summarization model to obtain a first feature vector corresponding to each number in the digital sequence;
[0015] Inputting the first feature vector into the MLP of the text summarization model to obtain a second feature vector, wherein the second feature vector is used to indicate whether the text corresponding to each number in the digital sequence is a summary;
[0016] The second text data is determined according to a plurality of second feature vectors of the digital sequence.
[0017] In an optional embodiment of the present disclosure, determining a text matching result of the first text data from a text database according to the second text data includes:
[0018] Acquire feature vectors of the second text data and the standard text data;
[0019] Determine matching text data from the text database by calculating the similarity between the feature vectors of the second text data and the standard text data, wherein the similarity between the feature vectors of the matching text data and the second text data is greater than or equal to a preset threshold;
[0020] The matching text data is used as a text matching result of the first text data.
[0021] In an optional embodiment of the present disclosure, the acquiring feature vectors of the second text data and the standard text data includes:
[0022] The feature vectors of the second text data and the standard text data are obtained through the BERT model.
[0023] In an optional embodiment of the present disclosure, the training process of the text summarization model includes:
[0024] Acquire a text data sample and a labeling result of the text data sample, wherein the labeling result is used to indicate whether each text in the text data sample belongs to a summary;
[0025] Performing character-level segmentation on the text data sample, and converting the segmented text data sample into a digital sequence sample according to a preset dictionary;
[0026] Build an initial text summarization model;
[0027] Taking the digital sequence sample corresponding to the text data sample as the input of the initial text summary model, taking the annotation result of the text data sample as the output of the initial text summary model, and training the initial text summary model;
[0028] When the loss function converges, the trained text summarization model is obtained.
[0029] In a second aspect, the present disclosure provides a text matching device, comprising:
[0030] An acquisition module, used for acquiring first text data to be matched;
[0031] A processing module, configured to perform de-colloquialization processing on the first text data through a text summary model to obtain the second text data, where the second text data is summary data of the first text data, and the text summary model is obtained by training with a BERT model and a multi-layer perceptron MLP;
[0032] The processing module is further configured to determine a text matching result of the first text data from a text database according to the second text data.
[0033] In an optional embodiment of the present disclosure, the processing module is specifically configured to:
[0034] Performing character-level segmentation on the first text data to obtain segmented first text data;
[0035] Converting the segmented first text data into a digital sequence according to a preset dictionary;
[0036] The digital sequence is input into the text summary model to obtain the second text data.
[0037] In an optional embodiment of the present disclosure, the processing module is specifically configured to:
[0038] Inputting the digital sequence into the BERT model of the text summarization model to obtain a first feature vector corresponding to each number in the digital sequence;
[0039] Inputting the first feature vector into the MLP of the text summarization model to obtain a second feature vector, wherein the second feature vector is used to indicate whether the text corresponding to each number in the digital sequence is a summary;
[0040] The second text data is determined according to a plurality of second feature vectors of the digital sequence.
[0041] In an optional embodiment of the present disclosure, the acquisition module is further used to:
[0042] Acquire feature vectors of the second text data and the standard text data;
[0043] The processing module is specifically used to determine matching text data from the text database by calculating the similarity between the feature vectors of the second text data and the standard text data, wherein the similarity between the feature vectors of the matching text data and the second text data is greater than or equal to a preset threshold;
[0044] The matching text data is used as a text matching result of the first text data.
[0045] In an optional embodiment of the present disclosure, the acquisition module is specifically used to: acquire feature vectors of the second text data and the standard text data through the BERT model.
[0046] In an optional embodiment of the present disclosure, the acquisition module is further used to acquire a text data sample and a labeling result of the text data sample, wherein the labeling result is used to indicate whether each text in the text data sample belongs to a summary;
[0047] The processing module is further used to perform character-level segmentation on the text data sample and convert the segmented text data sample into a digital sequence sample according to a preset dictionary;
[0048] Build an initial text summarization model;
[0049] Taking the digital sequence sample corresponding to the text data sample as the input of the initial text summary model, taking the annotation result of the text data sample as the output of the initial text summary model, and training the initial text summary model;
[0050] When the loss function converges, the trained text summarization model is obtained.
[0051] In a third aspect, the present disclosure provides an electronic device, the electronic device comprising:
[0052] A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the method according to any one of the first aspects of the present disclosure is implemented.
[0053] In a fourth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the method as described in any one of the first aspects of the present disclosure is implemented.
[0054] In a fifth aspect, the present disclosure provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method as described in any one of the first aspects of the present disclosure is implemented.
[0055] The disclosed embodiments provide a text matching method, apparatus, device and storage medium, which can be applied to the field of intelligent question answering, the method comprising: obtaining first text data to be matched, determining summary data of the first text data through a text summary model, wherein the summary data is the core data in the first text data, determining a text matching result of the first text data from a text database according to the summary data of the first text data, and the text matching result includes matching text data with the highest similarity to the first text data. The text summary model is obtained by using the BERT model and MLP training, and the text summary model can fully understand the semantic information of the text data by performing data analysis on the feature vectors of the text data, so that the summary data of the first text data can be obtained more accurately, providing data support for text matching, and thus improving the accuracy of text matching. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 The application scenario of the text matching method provided in the embodiment of the present disclosure is shown as follows: Figure 1 ;
[0057] Figure 2 The application scenario of the text matching method provided in the embodiment of the present disclosure is shown as follows: Figure 2 ;
[0058] Figure 3 Schematic diagram of the text matching method provided in the embodiment of the present disclosure Figure 1 ;
[0059] Figure 4 Schematic diagram of the text matching method provided in the embodiment of the present disclosure Figure 2 ;
[0060] Figure 5 A flowchart of a text matching model training method provided in an embodiment of the present disclosure;
[0061] Figure 6 A structural block diagram of a text matching device provided in an embodiment of the present disclosure;
[0062] Figure 7 A structural block diagram of an electronic device provided in an embodiment of the present disclosure.
[0063] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0064] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0065] The terms "first", "second", etc. in the specification, claims, and drawings of the embodiments of the present disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way are interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0066] It should be understood that the terms "including" and "having" and any variations thereof used herein are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0067] In the description of the embodiments of the present disclosure, the term "corresponding" may indicate a direct or indirect correspondence between two things, or an association relationship between the two things, or a relationship of indication and being indicated, configuration and being configured, and the like.
[0068] The rapid development of Internet technology in recent years has led to a rapid increase in online information. Due to the excessive amount of repetitive information, it is difficult for users to accurately and quickly find the required content when using traditional search engines. In addition, users' search needs vary from person to person and from time to time, and their own search intentions are difficult to clearly express with simple keyword searches, so it is naturally difficult to use traditional search engines to retrieve information that meets the needs. Although keyword search and matching algorithms are simple and easy to operate, the information at the grammatical and semantic levels has not been deeply mined, but only remains on the surface of the language. Therefore, the search efficiency of this search method is not high.
[0069] The transformation from text and graphics to a more user-friendly natural language interface is an inevitable trend in the development of Internet technology and information society. This transformation establishes a relationship between people and computers in the form of natural language question and answer. Users' desire to explore knowledge can be expressed through dialogue, allowing users to find and locate information that meets their search intentions in a large amount of data and information.
[0070] The Question Answering System (QA) was born in this context. The automatic question answering system uses natural language processing technology, which can provide users with correct answers while processing user questions, allowing users to easily and quickly retrieve content that meets their needs from the vast amount of Internet information.
[0071] The question-answering system includes a question-answering system based on a common question set, that is, a certain number of question-answer pairs are stored in the question-answering system knowledge base (database) in advance. When the question entered by the user matches the question in the system knowledge base, the system will directly return the answer to the user; when the question entered by the user does not match the question in the system knowledge base, the system cannot provide the correct answer, or it can further collect user questions to reconfirm the information.
[0072] For example, Figure 1 The application scenario of the text matching method provided in the embodiment of the present disclosure is shown as follows: Figure 1 ,like Figure 1 As shown, the scenario includes a server 11 and a terminal device 12. The user accesses the server 11 through the terminal device 12. The server 11 is provided with an intelligent question-and-answer system and a database corresponding to the question-and-answer system. A certain number of question-and-answer pairs are stored in the database.
[0073] The server 11 may be a server of an e-commerce platform, a social platform, a search platform, etc., and the present disclosure does not impose any restrictions on this. The terminal device 12 may be any device with a display function or a voice collection function, such as a smart phone, a smart TV, a tablet computer, a smart watch, etc.
[0074] For example, Figure 2 The application scenario of the text matching method provided in the embodiment of the present disclosure is shown as follows: Figure 2 ,like Figure 2 As shown, the scenario includes an intelligent robot, which includes a voice recognition device and / or a touch display screen. The intelligent robot also includes a communication device for connecting to the Internet. The intelligent robot can pre-store a certain number of question and answer pairs locally. The intelligent robot can provide intelligent question and answer services to users when connected to the Internet or disconnected from the Internet.
[0075] Based on any of the above scenarios, users can input questions through text or voice, and the question-and-answer system on the server or intelligent robot can use text matching technology to determine the standard question corresponding to the user input question from the database corresponding to the question-and-answer system, and after obtaining the reply information of the standard question, return the queried reply information to the user through voice or text.
[0076] At present, the existing question-answering system is mainly based on keyword matching technology, which can only match questions that are completely consistent with their descriptions, and the text matching success rate is low. Furthermore, sometimes the user's expression is more colloquial. Since the semantic information input by the user cannot be understood, the probability of text matching failure will be greatly increased, and the feedback effect of the question-answering system is not good.
[0077] In view of the above problems, the embodiments of the present disclosure provide a text matching method, which can be used to improve the accuracy of text matching in an intelligent question-answering system. Considering the colloquialism of user expressions, the summary data of the text is first extracted from the acquired text data, that is, the keywords of the text data are obtained by removing the colloquial data in the text data. Then, by calculating the text vector similarity, the matching text with a similarity greater than a preset threshold to the summary data is determined from the question-answering system knowledge base, the reply data corresponding to the matching text is obtained, and finally the reply data is fed back to the user.
[0078] In order to fully understand the semantics of text data instead of simply removing text, a pre-trained text summary model can be used to process the feature vector of text data and determine the summary data in the text data. Among them, the text summary model can use the language model BERT. When processing a single text (such as a word or character), the BERT model can consider the text before and after the text to obtain its meaning in the context. Therefore, the text summary determined by the model can more accurately represent the true meaning of the user input, while also removing colloquial text to provide data support for subsequent text matching.
[0079] The technical solution of the present disclosure is described in detail with specific embodiments below. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0080] Figure 3 Schematic diagram of the text matching method provided in the embodiment of the present disclosure Figure 1 The text matching method provided in this embodiment can be applied to Figure 1 The server shown or Figure 2 The intelligent robot shown.
[0081] like Figure 3 As shown, the method may include:
[0082] Step 101: Obtain first text data to be matched.
[0083] In this embodiment, the first text data generally includes colloquial text, and the colloquial text generally refers to words or characters that do not affect the intention of the sentence corresponding to the text data, such as "okay", "then", "I think", etc.
[0084] In one example of the present disclosure, the user inputs the first text data by text input. For example, the user accesses the server through a smart phone and enters the question "Why does my repayment show as unsuccessful?" in the question and answer column of the server page.
[0085] In an example of the present disclosure, a user inputs voice data, and a voice recognition technology is used to obtain first text data corresponding to the voice data. For example, a user initiates a voice question to an intelligent robot, and the voice recognition device of the intelligent robot obtains the voice data and converts the voice data into text data.
[0086] Step 102: De-colloquialize the first text data using a text summary model to obtain second text data, where the second text data is summary data of the first text data.
[0087] In this embodiment, the text summary model is used to extract summary data of the first text data.
[0088] Among them, summary data refers to the core data in text data, which plays a key role in expressing the meaning of the sentence and can be used to analyze the meaning of the sentence, such as the subject, predicate, object, etc. in the sentence.
[0089] The text summary model of this embodiment performs de-colloquialization processing on the text data, and its purpose is to remove non-core data in the sentence that plays an auxiliary role or has no effect on the expression of the sentence meaning. Among them, non-core data includes colloquial data. When non-core data is removed, it will not affect the expression of the sentence meaning, such as the attributive and adverbial modifiers in the sentence. It should be pointed out that not all colloquial data are non-core data, which requires the model to conduct a comprehensive analysis in combination with the words before and after each word in the sentence.
[0090] For example, the first text data is the above example "Why is my repayment not successful?" After data processing by the text summary model, the second text data can be "The repayment was not successful." It can be seen that the text summary model removes the non-core text including the colloquial text in the first text data by de-colloquializing the first text data, such as "why", "my", "show", and "what" in the above example.
[0091] Optionally, in some examples, before the first text data is de-colloquialized by the text summarization model, text preprocessing such as punctuation removal, case conversion, and segmentation is also included.
[0092] In an example of the present disclosure, the text summarization model is trained using the BERT model and a multi-layer perceptron (MLP).
[0093] Among them, the BERT model is a language model in the field of natural language processing (NLP), which can be used to encode text data and obtain the numerical feature vector corresponding to the text data. MLP includes input layer, hidden layer and output layer, and the different layers of MLP are fully connected. The input of the BERT model is used as the input of the text summary model, the output of the BERT model is used as the input of the MLP, and the output of the MLP is used as the output of the text summary model.
[0094] It should be noted that before inputting the first text data into the text summary model, the Chinese and / or English words in the first text data need to be converted into machine-recognizable natural language processing text, that is, a digital sequence, and then the digital sequence is input into the BERT model of the text summary model, and then through the MLP of the text summary model to obtain the summary data of the first text data.
[0095] Step 103: Determine a text matching result of the first text data from a text database according to the second text data.
[0096] In this embodiment, the text matching result is used to indicate the text data in the text database that matches the first text data. Specifically, the text matching result includes the matching text data in the text database that has the highest similarity to the first text data.
[0097] In an example of the present disclosure, a vector similarity calculation method of text data can be used to determine the text matching result of the first text data from the text database according to the second text data. Specifically, the text matching result can be determined by the following steps:
[0098] Step 1031: Obtain feature vectors of the second text data and the standard text data.
[0099] Specifically, the feature vectors of the second text data and the standard text data can be obtained through the BERT model. It should be understood that neither the second text data nor the standard text data contains colloquial text. Therefore, the second text data (or standard text data) can be directly converted into a machine-recognizable digital sequence through the preset dictionary of the BERT model, and then the digital sequence can be input into the BERT model to obtain the feature vector corresponding to the second text data (or the feature vector corresponding to the standard text data).
[0100] The preset dictionary of the BERT model includes the correspondence between text and numbers. For example, the text data is "The payment was not successful", and each word in the text corresponds to the numbers 42 43 24 25 12 13.
[0101] It should be noted that the above preset dictionary includes not only the correspondence between Chinese text and numbers, but also the correspondence between English text and numbers.
[0102] For English text, a byte pair encoder (BPE) algorithm can be used to segment English words into several parts, each of which corresponds to a number. For example, the English word "inaffable" can be segmented into three parts, namely ["in", "##aff", "##able", and the segmented words correspond to the numbers 3, 9, and 7 respectively.
[0103] From the above description, it can be seen that the BERT model is used to generate feature vectors corresponding to text data. The feature vectors corresponding to the text data include the feature vectors of each word in the text data. The feature vector of each word includes at least one of a word vector, a part-of-speech vector, and a position vector.
[0104] Among them, the character vector is obtained by vectorizing each character; the part-of-speech vector can represent the part of speech of each character, such as the vectors corresponding to the parts of speech such as verbs and nouns; the position vector can represent the position of each character in the text.
[0105] Exemplarily, the vector of the i-th character Xi can be identified as: Among them, Ew i The word vector representing the word Xi, Et i Represents the part-of-speech vector of the character Xi, Ep i Represents the position vector of the character Xi.
[0106] Step 1032: Determine matching text data from the text database by calculating the similarity between the feature vectors of the second text data and the standard text data.
[0107] In one example of the present disclosure, the similarity between the feature vectors of the second text data and the standard text data may be determined by calculating the cosine similarity between the feature vectors.
[0108] In an example of the present disclosure, the similarity between the feature vectors of the second text data and the standard text data may also be determined by a calculation formula such as Euclidean distance, Manhattan distance, etc.
[0109] In one example of the present disclosure, the similarity between the feature vectors of the matching text data and the second text data is greater than or equal to a preset threshold.
[0110] Optionally, in one example, if there are multiple standard text data whose similarity with the feature vector of the second text data is greater than or equal to a preset threshold (eg, 0.8), the standard text data with the similarity value closest to 1 may be used as the matching text data.
[0111] Step 1033: Use the matched text data as the text matching result of the first text data.
[0112] Optionally, after determining the text matching result of the first text data, the reply information corresponding to the matching text data can be obtained from the text database according to the text matching result. If the execution subject of this embodiment is a server, the server can send the reply information to the user's terminal device. If the execution subject of this embodiment is an intelligent robot, the intelligent robot can feedback the reply information to the user through voice or text, such as voice broadcasting the reply information, or displaying the reply information on a display.
[0113] Optionally, in some embodiments, other pre-trained models may be used to replace the BERT model, such as a GPT model, an XLNet model, etc., and this embodiment does not impose any limitation on this.
[0114] The text matching method provided in the above embodiment obtains the first text data to be matched, determines the summary data of the first text data through the text summary model, wherein the summary data is the core data in the first text data, and determines the text matching result of the first text data from the text database according to the summary data of the first text data, and the text matching result includes the matching text data with the highest similarity to the first text data. The text summary model of this embodiment is obtained by using the BERT model and MLP training. The text summary model can fully understand the semantic information of the text data by performing data analysis on the feature vectors of the text data, so that the summary data of the first text data can be obtained more accurately, providing data support for text matching, thereby improving the accuracy of text matching.
[0115] Based on the above embodiment, the internal processing process of the text summarization model in the above embodiment is described in detail below through a specific embodiment.
[0116] Figure 4 Schematic diagram of the text matching method provided in the embodiment of the present disclosure Figure 2 The method of this embodiment can also be applied to Figure 1 The server shown or Figure 2 The intelligent robot shown.
[0117] like Figure 4 As shown, the method may include:
[0118] Step 201: Perform character-level segmentation on first text data to obtain segmented first text data.
[0119] Step 202: Convert the segmented first text data into a digital sequence according to a preset dictionary.
[0120] In this embodiment, before character-level segmentation is performed on the first text data, start and end tags need to be added to the first text data. Specifically, a [CLS] tag is set at the beginning of a sentence in the first text data, and a [SEP] tag is set at the end of a sentence, and then character-level segmentation is performed, and the segmented first text data is converted into a digital sequence according to a preset dictionary.
[0121] Exemplarily, the first text data is “How to make payment settings”, and after adding start and end tags and performing character-level segmentation, “[CLS] How to make payment settings [SEP]” can be obtained.
[0122] The preset dictionary includes the correspondence between text and numbers, and also includes the numbers corresponding to the start tag and the end tag, for example, [CLS] corresponds to the number 101, and [SEP] corresponds to the number 102. Exemplarily, the above example "[CLS] How to make payment settings [SEP]" can be converted into a number sequence: [101 35 36 61 62 54 55 81 82 102] through the preset dictionary.
[0123] Optionally, in some examples, before character-level segmentation of the first text data, text processing such as punctuation removal and case conversion is also included. Among them, punctuation does not contribute much to semantic features and should be removed. Case conversion mainly involves English text, for example, converting "GOOD" to "good" to facilitate unified feature expression processing.
[0124] Step 203: Input the digital sequence into the BERT model of the text summarization model to obtain the first feature vector corresponding to each number in the digital sequence.
[0125] In this embodiment, the model parameters of the constructed BERT model can determine the dimension of the first feature vector. For example, a number in the digital sequence corresponds to a 768-dimensional feature vector, or a 1024-dimensional feature vector.
[0126] Step 204: Input the first feature vector into the MLP of the text summary model to obtain a second feature vector, where the second feature vector is used to indicate whether the text corresponding to each number in the digital sequence is a summary.
[0127] By obtaining multiple first feature vectors corresponding to the digital sequence through step 203, the multiple first feature vectors corresponding to the digital sequence are input into the MLP of the text summary model, and multiple second feature vectors corresponding to the digital sequence can be obtained, each of which is a two-dimensional vector. The multiple second feature vectors corresponding to the digital sequence can be regarded as an L*2 matrix, where L represents the length of the digital sequence (including [CLS] and [SEP] in the digital sequence).
[0128] Exemplarily, the text data "[CLS]How to set up payment [SEP]" is converted into a digital sequence: [101 3536 61 62 54 55 81 82 102], which is input into the text summarization model. After passing through the BERT model and the MLP, the output is ([0.3, 0.7], [0.9, 0.1], [0.9, 0.1], [0.8, 0.2], [0.8, 0.2], [0.1, 0.9], [0.1, 0.9], [0.2, 0.8], [0.2, 0.8], [0.7, 0.3]). Here, the first number in each array represents the probability that the current word is not in the summary, and the second number represents the probability that the current word is in the summary. It should be noted that since the digital sequence includes the numbers corresponding to the start and end tags, such as 101 and 102 above, during data analysis, the arrays at both ends of the MLP output should be removed, such as [0.3, 0.7] and [0.7, 0.3] above. Based on the middle eight arrays, the summary words are determined. For example, the sixth array [0.1, 0.9] corresponds to the word "payment", and this word can be determined as the summary word.
[0129] Step 205: Determine the second text data according to multiple second feature vectors of the digital sequence.
[0130] The text matching method provided in the above embodiments analyzes the feature vectors of the text data through the text summarization model to determine the summary data in the text data. The text summarization model includes two parts: the BERT model and the MLP. The BERT model is used to convert the digital sequence corresponding to the text data into multiple multi-dimensional feature vectors, and the MLP is used to determine the summary data of the text data according to the multiple multi-dimensional feature vectors. By using the text summarization model provided in this embodiment, the semantic information of the text data can be fully understood, so the summary data of the first text data can be obtained more accurately, providing data support for text matching and thus improving the accuracy of text matching.
[0131] Based on the above embodiments, the training process of the text summarization model in the above embodiments will be described in detail below through a specific example.
[0132] Exemplarily, Figure 5 is a schematic flowchart of the training method of the text summarization model provided by the embodiments of the present disclosure. As Figure 5 shown, the training method may include:
[0133] Step 301: Obtain a text data sample and the annotation result of the text data sample.
[0134] The annotation result is used to indicate whether each text in the text data sample belongs to the summary.
[0135] Before training the text summary model, you first need to collect a certain number of text data samples and the annotation results of each text data sample. The annotation results of the text data samples are manually annotated by annotators. The annotators need to mark whether each text in the text data sample belongs to the summary text. Each text corresponds to a label value.
[0136] For example, a label value of 1 indicates that the text belongs to summary text, and a label value of 0 indicates that the text does not belong to summary text. For example, the text data sample is "Want to reset payment settings", and its annotation result is "0000001111".
[0137] Step 302: segment the text data sample at the character level, and convert the segmented text data sample into a digital sequence sample according to a preset dictionary.
[0138] In this embodiment, before character-level segmentation of the text data sample, it is necessary to add start and end tags to the text data sample. Specifically, a [CLS] tag is set at the beginning of a sentence of the text data sample, and a [SEP] tag is set at the end of the sentence, and then character-level segmentation is performed, and the segmented text data sample is converted into a digital sequence sample according to a preset dictionary.
[0139] It should be noted that since the text summary model has requirements on the length of the input digital sequence samples, which is usually a fixed length, digital sequence samples that are not long enough can be padded with the label value "0", and digital sequence samples that exceed the fixed length can be truncated.
[0140] Optionally, in some examples, before character-level segmentation of text data samples, text processing such as punctuation removal and case conversion is also included.
[0141] Step 303: construct an initial text summary model.
[0142] Step 304: Use the digital sequence samples corresponding to the text data samples as inputs of the initial text summary model, use the annotation results of the text data samples as outputs of the initial text summary model, and train the initial text summary model.
[0143] Step 305: When the loss function converges, a trained text summarization model is obtained.
[0144] In this embodiment, the digital sequence sample corresponding to the text data sample is input into the initial text summary model to obtain the output result of the text data sample predicted by the model. According to the output result and the annotation result, the error of the model prediction is calculated, and the model parameters are updated through error back propagation until the model converges. In this embodiment, the model parameters include BERT model parameters and MLP parameters.
[0145] Specifically, the convergence condition of the text summary model can be: the model error is less than a preset error threshold; or the change in weight between two adjacent iterations is less than a set change threshold; or the set maximum number of iterations is reached. When the text summary model meets the above convergence conditions, the training is stopped to obtain a trained text summary model.
[0146] The text summary model constructed through the above model training process can obtain summary data in text data more accurately. The summary data can represent the true meaning of the user input and does not include colloquial data, providing data support for subsequent database text matching.
[0147] The embodiments of the present disclosure can divide the text matching device into functional modules according to the above method embodiments. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiments of the present disclosure is schematic and is only a logical functional division. There may be other division methods in actual implementation. The following is an example of dividing each functional module according to each function.
[0148] For example, Figure 6 This is a structural block diagram of a text matching device provided in an embodiment of the present disclosure. For ease of explanation, only the parts related to the embodiment of the present disclosure are shown.
[0149] like Figure 6 As shown, the text matching device 400 provided in this embodiment includes: an acquisition module 401 and a processing module 402 .
[0150] An acquisition module 401 is used to acquire first text data to be matched;
[0151] A processing module 402 is used to perform de-colloquialization processing on the first text data through a text summary model to obtain the second text data, where the second text data is summary data of the first text data, and the text summary model is obtained by training with a BERT model and a multi-layer perceptron MLP;
[0152] The processing module 402 is further configured to determine a text matching result of the first text data from a text database according to the second text data.
[0153] In an optional embodiment of the present disclosure, the processing module 402 is specifically configured to:
[0154] Performing character-level segmentation on the first text data to obtain segmented first text data;
[0155] Converting the segmented first text data into a digital sequence according to a preset dictionary;
[0156] The digital sequence is input into the text summary model to obtain the second text data.
[0157] In an optional embodiment of the present disclosure, the processing module 402 is specifically configured to:
[0158] Inputting the digital sequence into the BERT model of the text summarization model to obtain a first feature vector corresponding to each number in the digital sequence;
[0159] Inputting the first feature vector into the MLP of the text summarization model to obtain a second feature vector, wherein the second feature vector is used to indicate whether the text corresponding to each number in the digital sequence is a summary;
[0160] The second text data is determined according to a plurality of second feature vectors of the digital sequence.
[0161] In an optional embodiment of the present disclosure, the acquisition module 401 is further configured to:
[0162] Acquire feature vectors of the second text data and the standard text data;
[0163] The processing module 402 is specifically configured to determine matching text data from the text database by calculating the similarity between the feature vectors of the second text data and the standard text data, wherein the similarity between the feature vectors of the matching text data and the second text data is greater than or equal to a preset threshold;
[0164] The matching text data is used as a text matching result of the first text data.
[0165] In an optional embodiment of the present disclosure, the acquisition module 401 is specifically used to: acquire feature vectors of the second text data and the standard text data through the BERT model.
[0166] In an optional embodiment of the present disclosure, the acquisition module 401 is further used to acquire a text data sample and a labeling result of the text data sample, wherein the labeling result is used to indicate whether each text in the text data sample belongs to a summary;
[0167] The processing module 402 is further used to perform character-level segmentation on the text data sample and convert the segmented text data sample into a digital sequence sample according to a preset dictionary;
[0168] Build an initial text summarization model;
[0169] Taking the digital sequence sample corresponding to the text data sample as the input of the initial text summary model, taking the annotation result of the text data sample as the output of the initial text summary model, and training the initial text summary model;
[0170] When the loss function converges, the trained text summarization model is obtained.
[0171] The text matching device provided in the embodiment of the present disclosure is used to execute the technical solution provided by any of the aforementioned method embodiments. Its implementation principle and technical effects are similar and will not be repeated here.
[0172] Figure 7 This is a structural block diagram of an electronic device provided by an embodiment of the present disclosure. Figure 7 As shown, the electronic device 500 of this embodiment may include:
[0173] At least one processor 501 ( Figure 7 Only one processor is shown); and
[0174] A memory 502 is communicatively connected to the at least one processor; wherein,
[0175] The memory 502 stores a computer program executable by the at least one processor 501 , and the computer program is executed by the at least one processor 501 so that the electronic device 500 can execute the technical solution of the first device in any of the aforementioned method embodiments.
[0176] Optionally, the memory 502 may be independent or integrated with the processor 501 .
[0177] When the memory 502 is a device independent of the processor 501 , the electronic device 500 further includes a bus 503 for connecting the memory 502 and the processor 501 .
[0178] The electronic device provided by the embodiments of the present disclosure can execute the technical solution provided by any of the aforementioned method embodiments, and its implementation principles and technical effects are similar, which will not be repeated here.
[0179] An embodiment of the present disclosure further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, it is used to implement the technical solution provided by any of the aforementioned method embodiments.
[0180] The embodiments of the present disclosure further provide a computer program product, including a computer program, which implements the technical solution provided by any of the aforementioned method embodiments when executed by a processor.
[0181] The embodiment of the present disclosure also provides a chip, including: a processing module and a communication interface, and the processing module can execute the technical solution provided by any of the aforementioned method embodiments.
[0182] Furthermore, the chip also includes a storage module (such as a memory), the storage module is used to store instructions, the processing module is used to execute the instructions stored in the storage module, and the execution of the instructions stored in the storage module enables the processing module to execute the technical solution provided by any of the aforementioned method embodiments.
[0183] It should be understood that the processor may be a central processing unit (CPU), other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented by a hardware processor or implemented by a combination of hardware and software modules in the processor.
[0184] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.
[0185] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present disclosure is not limited to only one bus or one type of bus.
[0186] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.
[0187] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device.
[0188] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A text matching method, characterized in that: include: Acquire first text data to be matched; The first text data is de-colloquialized by a text summary model to obtain second text data, where the second text data is summary data of the first text data, and the text summary model is obtained by training with a BERT model and a multi-layer perceptron MLP; Determining a text matching result of the first text data from a text database according to the second text data; The step of performing de-colloquialization processing on the first text data by using the text summarization model to obtain the second text data includes: Performing character-level segmentation on the first text data to obtain segmented first text data; Converting the segmented first text data into a digital sequence according to a preset dictionary; Inputting the digital sequence into the BERT model of the text summarization model to obtain a first feature vector corresponding to each number in the digital sequence; Inputting the first feature vector into the MLP of the text summarization model to obtain a second feature vector, wherein the second feature vector is used to indicate whether the text corresponding to each number in the digital sequence is a summary; The second text data is determined according to a plurality of second feature vectors of the digital sequence.
2. The method according to claim 1, characterized in that The determining a text matching result of the first text data from a text database according to the second text data includes: Obtaining feature vectors of the second text data and standard text data; Determine matching text data from the text database by calculating the similarity between the feature vectors of the second text data and the standard text data, wherein the similarity between the feature vectors of the matching text data and the second text data is greater than or equal to a preset threshold; The matching text data is used as a text matching result of the first text data.
3. The method according to claim 2, characterized in that The obtaining of the feature vectors of the second text data and the standard text data includes: The feature vectors of the second text data and the standard text data are obtained through the BERT model.
4. The method according to claim 1, characterized in that: The training process of the text summarization model includes: Acquire a text data sample and a labeling result of the text data sample, wherein the labeling result is used to indicate whether each text in the text data sample belongs to a summary; Performing character-level segmentation on the text data sample, and converting the segmented text data sample into a digital sequence sample according to a preset dictionary; Build an initial text summarization model; Taking the digital sequence sample corresponding to the text data sample as the input of the initial text summary model, taking the annotation result of the text data sample as the output of the initial text summary model, and training the initial text summary model; When the loss function converges, the trained text summarization model is obtained.
5. A text matching device, characterized in that: include: An acquisition module, used for acquiring first text data to be matched; A processing module is used to perform de-colloquialization processing on the first text data through a text summary model to obtain second text data, where the second text data is summary data of the first text data, and the text summary model is obtained by training with a BERT model and a multi-layer perceptron MLP; the processing module is specifically used to perform character-level segmentation on the first text data to obtain segmented first text data; convert the segmented first text data into a digital sequence according to a preset dictionary; input the digital sequence into the BERT model of the text summary model to obtain a first feature vector corresponding to each number in the digital sequence; input the first feature vector into the MLP of the text summary model to obtain a second feature vector, where the second feature vector is used to indicate whether the text corresponding to each number in the digital sequence is a summary; determine the second text data according to multiple second feature vectors of the digital sequence; The processing module is further configured to determine a text matching result of the first text data from a text database according to the second text data.
6. The device according to claim 5, characterized in that The acquisition module is further used for: Obtaining feature vectors of the second text data and standard text data; The processing module is specifically used to determine matching text data from the text database by calculating the similarity between the feature vectors of the second text data and the standard text data, wherein the similarity between the feature vectors of the matching text data and the second text data is greater than or equal to a preset threshold; The matching text data is used as a text matching result of the first text data.
7. The device according to claim 6, characterized in that The acquisition module is specifically used to: obtain feature vectors of the second text data and the standard text data through the BERT model.
8. The device according to claim 5, characterized in that The acquisition module is further used to acquire a text data sample and a labeling result of the text data sample, wherein the labeling result is used to indicate whether each text in the text data sample belongs to a summary; The processing module is further used to perform character-level segmentation on the text data sample and convert the segmented text data sample into a digital sequence sample according to a preset dictionary; Build an initial text summarization model; Taking the digital sequence sample corresponding to the text data sample as the input of the initial text summary model, taking the annotation result of the text data sample as the output of the initial text summary model, and training the initial text summary model; When the loss function converges, the trained text summarization model is obtained.
9. An electronic device, characterized in that: The electronic device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the method according to any one of claims 1 to 4 when executed by the processor.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.
11. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 4 when being executed by a processor.
