Text matching method, device, electronic device and storage medium
By extracting and fusing text features, combined with search type features, the problem of low text matching accuracy in the existing technology is solved, and a more accurate and efficient text matching effect is achieved.
Patent Information
- Application Number
- CN202311236667.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-09-22
AI Technical Summary
Existing text matching methods have low accuracy in recommendation and search scenarios, and cannot effectively determine whether two pieces of text express the same semantic information.
By obtaining feature extraction of query text and content text, determine their associated information and perform feature conversion, fuse query features, content features and associated features, combine search type features for matching, and use technologies such as BM25 algorithm and feature splicing to improve matching accuracy.
Significantly improves the accuracy of text matching, overcomes matching errors caused by using only semantic models, considers the semantic and statistical dimensions of text through multi-dimensional feature fusion, enhances the unity and uniqueness of different types of semantic discrimination, and improves content Text filtering efficiency.
Smart Images

Figure CN117725153B
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a text matching method, device, electronic device and storage medium. Background Art
[0002] The text matching task is a basic task in the field of natural language processing, which aims to determine whether two sentences express the same semantic information. Text matching mainly calculates the similarity between two texts to select the most matching content, such as selecting similar content in search scenarios, matching the most similar questions in the question library in question-answering scenarios and returning the corresponding answers, etc.
[0003] Text matching is widely used in scenarios such as recommendation and search. However, in existing solutions, only the similarity between two texts is calculated, which reduces the accuracy of text matching. Summary of the invention
[0004] The embodiments of the present application provide a text matching method, device, electronic device and storage medium, which can effectively improve the accuracy of text matching.
[0005] The present application provides a text matching method, including:
[0006] Obtaining a query text and a content text searched based on the query text;
[0007] Performing feature extraction on the query text and the content text respectively to obtain query features corresponding to the query text and content features corresponding to the content text;
[0008] Determining association information between the query text and the content text, and performing feature conversion on the association information to obtain association features;
[0009] The query feature and the associated feature are fused to obtain a first fused feature, and the content feature and the associated feature are fused to obtain a second fused feature;
[0010] A search type feature is obtained, and based on the first fusion feature, the second fusion feature and the search type feature, the query text is matched with the content text to obtain a matching result.
[0011] Optionally, in some embodiments, determining association information between the query text and the content text includes:
[0012] Performing morpheme analysis on the query text to obtain at least one query morpheme;
[0013] Calculating the correlation between each query morpheme and the content text to obtain a morpheme correlation score;
[0014] The weight of each query morpheme is determined, and the morpheme relevance scores are weighted based on the weight to obtain association information between the query text and the content text.
[0015] Optionally, in some embodiments, performing feature conversion on the association information to obtain association features includes:
[0016] Normalizing the associated information to obtain processed associated information;
[0017] Based on the dimension of the query feature, the processed association information is dimensionally expanded to obtain the association feature.
[0018] Optionally, in some embodiments, fusing the query feature with the association feature to obtain a first fused feature, and fusing the content feature with the association feature to obtain a second fused feature, includes:
[0019] Perform feature concatenation on the query feature and the associated feature to obtain a first fusion feature;
[0020] The content feature and the associated feature are concatenated to obtain a second fused feature.
[0021] Optionally, in some embodiments, the acquiring the search type feature, matching the query text with the content text based on the first fusion feature, the second fusion feature and the search type feature to obtain a matching result, includes:
[0022] Obtain at least one preset search type, and determine a search type feature corresponding to the preset search type based on a text matching model;
[0023] Adding the first fusion feature and the search type feature to obtain a fused feature;
[0024] Based on the similarity information between the fused feature and the second fused feature, a matching result between the query text and the content text is determined.
[0025] Optionally, in some embodiments, the adding the first fusion feature and the search type feature to obtain a fused feature includes:
[0026] Respectively adding the first fusion feature to the search type feature corresponding to each preset search type to obtain at least one fused feature;
[0027] The determining, based on the similarity between the fused feature and the second fused feature, a matching result between the query text and the content text includes:
[0028] Calculating the similarity between each fused feature and the second fused feature respectively, and obtaining similarity information between the query text and the content text in each preset search type;
[0029] The current search type of the query text and the content text is determined based on the similar information, and the current search type and the similar information corresponding to the current search type are used as matching results.
[0030] Optionally, in some embodiments, before obtaining at least one preset search type and determining the search type feature corresponding to the preset search type based on the text matching model, the method further includes:
[0031] Acquire a training sample set, wherein the training sample set includes at least one query sample and a content sample searched based on the query sample;
[0032] Obtain at least one preset search type, and classify the query sample based on the preset search type to obtain a target search type corresponding to the query sample;
[0033] The preset text matching model is trained using the training sample set and the target search type to obtain a text matching model.
[0034] Optionally, in some embodiments, the using the training sample set and the target search type to train a preset text matching model to obtain a text matching model includes:
[0035] Using a preset text matching model to extract features from the query sample and the content sample respectively, to obtain query sample features and content sample features;
[0036] Initializing the features of the preset search type to obtain initial search type features;
[0037] Based on the query sample feature, the content sample feature and the initial search type feature, the query sample is matched with the content sample to obtain a predicted matching result, wherein the predicted matching result includes a predicted search type corresponding to the query sample;
[0038] The preset text matching model is converged using the predicted matching result and the actual matching result to obtain a text matching model, wherein the actual matching result includes the target search type corresponding to the query sample.
[0039] Optionally, in some embodiments, matching the query sample with the content sample based on the query sample feature, the content sample feature and the initial search type feature to obtain a predicted matching result includes:
[0040] Determining sample association information between the query sample and the content sample, and performing feature conversion on the sample association information to obtain sample association features;
[0041] The query sample feature and the associated sample feature are spliced to obtain a first spliced feature, and the content feature and the associated feature are spliced to obtain a second spliced feature;
[0042] Based on the first splicing feature, the second splicing feature and the initial search type feature, the query sample is matched with the content sample to obtain a predicted matching result.
[0043] Optionally, in some embodiments, matching the query sample with the content sample based on the first splicing feature, the second splicing feature and the initial search type feature to obtain a predicted matching result includes:
[0044] Respectively adding the first concatenated feature and the initial search type feature corresponding to each preset search type to obtain at least one fused sample feature;
[0045] The similarity between each fused sample feature and the second splicing feature is calculated respectively, and a predicted matching result is determined based on the calculation result.
[0046] Optionally, in some embodiments, respectively calculating the similarity between each fused sample feature and the second splicing feature, and determining the predicted matching result based on the calculation result, includes:
[0047] Calculating the similarity between each fused sample feature and the second spliced feature respectively, and obtaining similarity results between the query sample and the content sample in each preset search type;
[0048] The predicted search types of the query sample and the content sample are determined based on the similar results, and the predicted search type and the similar results corresponding to the predicted search type are used as predicted matching results.
[0049] Accordingly, the embodiment of the present application further provides a text matching device, including:
[0050] An acquisition unit, used to acquire a query text and a content text searched based on the query text;
[0051] An extraction unit, used to extract features from the query text and the content text respectively, to obtain query features corresponding to the query text and content features corresponding to the content text;
[0052] A conversion unit, used to determine the association information between the query text and the content text, and perform feature conversion on the association information to obtain association features;
[0053] A fusion unit, configured to fuse the query feature and the associated feature to obtain a first fused feature, and to fuse the content feature and the associated feature to obtain a second fused feature;
[0054] The matching unit is used to obtain a search type feature, and match the query text with the content text based on the first fusion feature, the second fusion feature and the search type feature to obtain a matching result.
[0055] Optionally, in some embodiments, the conversion unit includes an association subunit and a conversion subunit, as follows:
[0056] The association subunit can be specifically used to perform morpheme analysis on the query text to obtain at least one query morpheme; calculate the correlation between each query morpheme and the content text to obtain a morpheme correlation score; determine the weight of each query morpheme, and perform weighted processing on the morpheme correlation score based on the weight to obtain association information between the query text and the content text.
[0057] Optionally, in some embodiments, the conversion subunit may be specifically used to normalize the association information to obtain processed association information; and based on the dimension of the query feature, perform dimension expansion on the processed association information to obtain an association feature.
[0058] Optionally, in some embodiments, the fusion unit may be specifically configured to perform feature splicing on the query feature and the associated feature to obtain a first fused feature; and perform feature splicing on the content feature and the associated feature to obtain a second fused feature.
[0059] Optionally, in some embodiments, the matching unit can be specifically used to obtain at least one preset search type, determine the search type feature corresponding to the preset search type based on a text matching model; add the first fusion feature and the search type feature to obtain a fused feature; and determine the matching result between the query text and the content text based on similarity information between the fused feature and the second fusion feature.
[0060] Optionally, in some embodiments, the matching unit can be specifically used to add the first fused feature and the search type feature corresponding to each preset search type, respectively, to obtain at least one fused feature; calculate the similarity between each fused feature and the second fused feature, respectively, to obtain similarity information between the query text and the content text in each preset search type; determine the current search type of the query text and the content text based on the similarity information, and take the current search type and the similarity information corresponding to the current search type as the matching result.
[0061] Optionally, in some embodiments, the text matching device may further include a training unit, and the training unit may include an acquisition subunit and a training subunit, as follows:
[0062] The acquisition subunit may be specifically used to acquire a training sample set, the training sample set including at least one query sample and a content sample searched based on the query sample; acquire at least one preset search type, and classify the query sample based on the preset search type to obtain a target search type corresponding to the query sample;
[0063] The training subunit can be specifically used to train a preset text matching model using the training sample set and the target search type to obtain a text matching model.
[0064] Optionally, in some embodiments, the training sub-unit can be specifically used to use a preset text matching model to extract features from the query sample and the content sample respectively to obtain query sample features and content sample features; perform feature initialization on the preset search type to obtain initial search type features; match the query sample with the content sample based on the query sample features, the content sample features and the initial search type features to obtain a predicted matching result, wherein the predicted matching result includes the predicted search type corresponding to the query sample; use the predicted matching result and the actual matching result to converge the preset text matching model to obtain a text matching model, wherein the actual matching result includes the target search type corresponding to the query sample.
[0065] Optionally, in some embodiments, the training subunit can be specifically used to determine the sample association information between the query sample and the content sample, and perform feature conversion on the sample association information to obtain sample association features; splice the query sample features and the associated sample features to obtain a first spliced feature, and splice the content features and the associated features to obtain a second spliced feature; based on the first spliced feature, the second spliced feature and the initial search type feature, match the query sample with the content sample to obtain a predicted matching result.
[0066] Optionally, in some embodiments, the training subunit can be specifically used to add the first splicing feature and the initial search type feature corresponding to each preset search type, respectively, to obtain at least one fused sample feature; respectively calculate the similarity between each fused sample feature and the second splicing feature, and determine the predicted matching result based on the calculation result.
[0067] Optionally, in some embodiments, the training subunit can be specifically used to calculate the similarity between each fused sample feature and the second splicing feature, respectively, to obtain similarity results between the query sample and the content sample in each preset search type; based on the similarity results, the predicted search type of the query sample and the content sample is determined, and the predicted search type and the similarity results corresponding to the predicted search type are used as predicted matching results.
[0068] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores multiple instructions, and the instructions are suitable for a processor to load to execute the steps in any text matching method provided in the embodiment of the present application.
[0069] In addition, an embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in any text matching method provided in the embodiment of the present application are implemented.
[0070] According to one aspect of the present application, a computer program product or a computer program is provided, which includes computer instructions, which are 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, so that the computer device executes the methods provided in various optional implementations of the above-mentioned text matching aspects.
[0071] This embodiment can obtain a query text and a content text searched based on the query text; then, feature extraction is performed on the query text and the content text respectively to obtain a query feature corresponding to the query text and a content feature corresponding to the content text; then, the association information between the query text and the content text is determined, and the association information is feature converted to obtain an association feature; then, the query feature and the association feature are fused to obtain a first fused feature, and the content feature and the association feature are fused to obtain a second fused feature; then, a search type feature is obtained, and based on the first fused feature, the second fused feature and the search type feature, the query text is matched with the content text to obtain a matching result. This solution can effectively improve the accuracy of text matching. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0073] Figure 1 is a scenario diagram of a text matching method provided in an embodiment of the present application;
[0074] Figure 2 is a first flow chart of the text matching method provided in an embodiment of the present application;
[0075] Figure 3 is a second flow chart of the text matching method provided in an embodiment of the present application;
[0076] Figure 4 is a third flow chart of the text matching method provided in an embodiment of the present application;
[0077] Figure 5 is a first structural schematic diagram of a text matching device provided in an embodiment of the present application;
[0078] Figure 6 is a second structural schematic diagram of the text matching device provided in an embodiment of the present application;
[0079] Figure 7 is a third structural diagram of the text matching device provided in an embodiment of the present application;
[0080] Figure 8 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0081] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0082] The principles of the present application are illustrated by implementation in an appropriate computing environment. In the following description, the specific embodiments of the present application will be described with reference to the steps and symbols executed by one or more computers, unless otherwise stated. Therefore, these steps and operations will be mentioned several times as being executed by a computer, and the computer execution referred to herein includes the operation of a computer processing unit by an electronic signal representing data in a structured form. This operation converts the data or maintains it at a location in the memory system of the computer, which can be reconfigured or otherwise change the operation of the computer in a manner familiar to testers in the field. The data structure maintained by the data is the physical location of the memory, which has specific characteristics defined by the data format. However, the principles of the present application are described in the above text, which does not represent a limitation, and testers in the field will understand that the following various steps and operations can also be implemented in hardware.
[0083] The term "unit" used in this article can be regarded as a software object executed on the computing system. The different components, units, engines and services described in this article can be regarded as implementation objects on the computing system. The devices and methods described in this article can be implemented in software, and of course can also be implemented in hardware, all within the scope of protection of this application.
[0084] The terms "first", "second", and "third" in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but some embodiments also include steps or units that are not listed, or some embodiments also include other steps or units inherent to these processes, methods, products, or devices.
[0085] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0086] The embodiments of the present application provide a text matching method, device, electronic device and storage medium. The text matching device can be integrated in an electronic device, which can be a server or a terminal.
[0087] The text matching method provided in the embodiment of the present application mainly utilizes the natural language processing technology in the field of artificial intelligence to achieve matching between the query text and the content text.
[0088] Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can respond in a similar way to human intelligence. Artificial intelligence is to study the design principles and implementation methods of various intelligent machines so that machines have the functions of perception, reasoning and decision-making. Artificial intelligence technology is a comprehensive discipline that covers a wide range of fields, including both hardware-level technology and software-level technology. Among them, artificial intelligence software technology mainly includes computer vision technology, machine learning / deep learning and other directions.
[0089] Among them, natural language processing (NLP) is an important direction in the fields of computer science and artificial intelligence. It studies various theories and methods that can achieve effective communication between people and computers using natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Therefore, research in this field will involve natural language, that is, the language used by people in daily life, so it is closely related to the study of linguistics. Natural language processing technology usually includes text processing, semantic understanding, machine translation, robot question answering, knowledge graph and other technologies. Among them, the key technologies of speech technology (Speech Technology) include automatic text matching technology (ASR), speech synthesis technology (TTS) and voiceprint recognition technology. Enabling computers to listen, see, speak and feel is the development direction of human-computer interaction in the future, among which speech has become one of the most promising human-computer interaction methods in the future.
[0090] For example, Figure 1As shown, first, the electronic device integrated with the text matching device can obtain the query text and the content text searched based on the query text; then, feature extraction is performed on the query text and the content text respectively to obtain the query feature corresponding to the query text and the content feature corresponding to the content text; then, the association information between the query text and the content text is determined, and the feature conversion is performed on the association information to obtain the association feature; then, the query feature and the association feature are fused to obtain the first fusion feature, and the content feature and the association feature are fused to obtain the second fusion feature; then, the search type feature is obtained, and the query text is matched with the content text based on the first fusion feature, the second fusion feature and the search type feature to obtain the matching result. Since the scheme obtains the statistical matching feature of text matching by determining the association information between the query text and the content text, and then fuses the statistical matching feature with the semantic feature of the text, some common matching errors caused by using only the semantic model are overcome, and by classifying the search tasks and constructing multi-type text matching, the task-related prior knowledge is integrated with the semantic representation, which greatly improves the accuracy of text matching. This solution greatly enriches the semantic features by adding features that enter the statistical dimension into the semantic model, and explicitly integrates different search types into the model, enhancing the unity and uniqueness of different types of semantic discrimination. Because this solution considers the semantic and statistical dimensions of the text through multi-dimensional feature fusion, the feature information of text matching is more sufficient, the consideration is more comprehensive, and the matching results are more prepared, which greatly improves the accuracy of text matching and further improves the efficiency of content text screening.
[0091] It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0092] This embodiment will be described from the perspective of a text matching device, which can be specifically integrated into an electronic device, which can be a server or a terminal. The terminal can include a mobile phone, a tablet computer, a laptop computer, and a personal computer (PC).
[0093] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart watch, etc., but is not limited to this. The terminal and the server can be directly or indirectly connected via wired or wireless communication, and this application does not limit this.
[0094] A text matching method comprises: obtaining a query text and a content text searched based on the query text; then, performing feature extraction on the query text and the content text respectively to obtain a query feature corresponding to the query text and a content feature corresponding to the content text; then, determining association information between the query text and the content text, and performing feature conversion on the association information to obtain an association feature; then, fusing the query feature and the association feature to obtain a first fused feature, and fusing the content feature and the association feature to obtain a second fused feature; then, obtaining a search type feature, and matching the query text with the content text based on the first fused feature, the second fused feature and the search type feature to obtain a matching result.
[0095] like Figure 2 As shown, the specific process of the text matching method can be as follows:
[0096] 101. Obtain a query text and a content text searched based on the query text.
[0097] The query text (query) may refer to the information needed for query or search, such as a word, a sentence, or a paragraph of text, etc., or in the form of a table, image, etc. The content text (doc) may refer to the information queried or searched using the query text, such as a paragraph, an article, or an image, table, etc. The searched content text may be one or more, which may be determined based on the actual search results.
[0098] For example, when a text matching request is received, the query text can be obtained according to the text matching request. For example, when text matching is required, a text matching request can be generated and sent to a text matching device, so that the text matching device can obtain the query text, and use the obtained query text to search to obtain the content text, and then match the query text with the content text to generate a matching result, and then the matching result can be sorted and displayed, etc.
[0099] 102. Perform feature extraction on the query text and the content text respectively to obtain query features corresponding to the query text and content features corresponding to the content text.
[0100] After obtaining the query text and the content text, feature extraction can be performed on the query text and the content text. For example, feature extraction can be performed on the query text to obtain query features; feature extraction can be performed on the content text to obtain content features. For example, the extracted query features can be recorded as Embedding A, and the content features can be recorded as Embedding B.
[0101] There are many ways to extract features from the query text and the content text, for example, a trained text matching model can be used to extract features, etc. For example, the query text can be extracted using a text matching model to obtain query features corresponding to the query text; the content text can be extracted using a text matching model to obtain content features corresponding to the content text.
[0102] Among them, the text matching model can be a bidirectional encoder representation from transformer (BidirectionalEncoder Representations from Transformers, BERT) model, or other matching models, etc., which are not limited here.
[0103] 103. Determine association information between the query text and the content text, and perform feature conversion on the association information to obtain association features.
[0104] There are many ways to determine the association information between the query text and the content text. For example, the correlation score between the query text and the content text can be calculated, such as the cosine similarity between them, the BM25 score, or the dot product similarity, etc. The correlation between the query text and the content text can also be calculated using a semantic matching model, a text classification model, a click-through rate prediction model, etc.
[0105] For example, "determine the association information between the query text and the content text", specifically, the query text can be parsed morphemically to obtain at least one query morpheme; the correlation between each query morpheme and the content text can be calculated to obtain a morpheme correlation score; the weight of each query morpheme can be determined, and the morpheme correlation score can be weighted based on the weight to obtain the association information between the query text and the content text.
[0106] For example, BM25 can be used to parse Query and generate morphemes q i ; Then, for each search result Doc, calculate each morpheme q i The correlation score with Doc, finally, q i The relevance score of Query and Doc is obtained by weighted summation relative to the relevance score of Doc. The calculation formula can be as follows:
[0107]
[0108] Where k1 and b are adjustment factors, fi is the frequency of qi in d, and qfi is the frequency of qi in Query. dl is the length of content text d, and avgdl is the average length of all content texts. Where n(qi) is the number of texts containing qi.
[0109] There are many ways to perform feature conversion on the associated information. For example, the associated information may be normalized or discretized, etc. Different feature conversion methods may be selected according to actual needs.
[0110] For example, “perform feature conversion on the associated information to obtain associated features”, specifically, the associated information may be normalized to obtain processed associated information; and based on the dimension of the query feature, the processed associated information may be dimensionally expanded to obtain associated features.
[0111] For example, since the BM25 score has no upper limit, it can be normalized to obtain an interpretable score for a given query text and content text. For example, normalization can be performed as follows:
[0112]
[0113] Among them, the numerator is the BM25 score of the current query-doc, and the numerator is the sum of the BM25 scores of all docs to be calculated under the query.
[0114] Next, the normalized BM25 score can be expanded to have the same dimensions as the query features and content features, as follows:
[0115]
[0116] Among them, W bm25 Refers to the dimension of the query feature.
[0117] 104. The query feature and the associated feature are fused to obtain a first fused feature, and the content feature and the associated feature are fused to obtain a second fused feature.
[0118] There are many ways to fuse features, for example, you can concatenate two features, you can weight the two features, you can cross the two features, and so on.
[0119] For example, the query feature and the associated feature may be concatenated to obtain a first fused feature; and the content feature and the associated feature may be concatenated to obtain a second fused feature.
[0120] 105. Obtain a search type feature, and match the query text with the content text based on the first fusion feature, the second fusion feature, and the search type feature to obtain a matching result.
[0121] Among them, the search type feature may refer to the feature of a preset search type. The preset search type may be set according to actual needs, and the number of types may also be adjusted according to actual needs. For example, the preset search types may include question-and-answer search types, topic search types, and interpretation search types, etc. The search type feature may be specifically trained using a text matching model and determined based on the trained text matching model, or may be obtained in other ways.
[0122] For example, at least one preset search type can be obtained, and the search type feature corresponding to the preset search type can be determined based on a text matching model; the first fusion feature and the search type feature are added to obtain a fused feature; based on similarity information between the fused feature and the second fusion feature, the matching result between the query text and the content text is determined.
[0123] For example, when there are multiple preset search types, at least one preset search type can be obtained, and the search type feature corresponding to the preset search type can be determined based on the text matching model; the first fusion feature is added to the search type feature corresponding to each preset search type to obtain at least one fused feature; the similarity between each fused feature and the second fusion feature is calculated to obtain similarity information between the query text and the content text in each preset search type; the current search type of the query text and the content text is determined based on the similarity information, and the current search type and the similarity information corresponding to the current search type are used as the matching result.
[0124] In order to improve the efficiency of text matching, the preset text matching model is first trained, and then the trained text matching model is used to match the query text and the content text. Optionally, the text matching model can be trained by multiple training samples. Specifically, it can be trained by other devices and then provided to the text matching device, or it can also be trained by the text matching device itself. For example, before the step of "obtaining at least one preset search type and determining the search type features corresponding to the preset search type based on the text matching model", the text matching method can also include:
[0125] Acquire a training sample set, wherein the training sample set includes at least one query sample and a content sample searched based on the query sample;
[0126] Obtain at least one preset search type, and classify the query sample based on the preset search type to obtain a target search type corresponding to the query sample;
[0127] The preset text matching model is trained using the training sample set and the target search type to obtain a text matching model.
[0128] Among them, the model structure of the preset text matching model may include an encoder, a decoder, a feature extractor, etc., which can be set according to actual needs and is not limited here.
[0129] For example, the preset search types may include question-answer search type, topic search type, and interpretation search type, etc. Then, the query samples and the content samples corresponding to the query samples are classified to determine which of these types their search types belong to.
[0130] Optionally, in some embodiments, "the preset text matching model is trained using the training sample set and the target search type to obtain a text matching model". Specifically, the preset text matching model can be used to extract features from the query sample and the content sample respectively to obtain query sample features and content sample features; features of the preset search type are initialized to obtain initial search type features; based on the query sample features, the content sample features and the initial search type features, the query sample is matched with the content sample to obtain a predicted matching result, and the predicted matching result includes the predicted search type corresponding to the query sample; the preset text matching model is converged using the predicted matching result and the actual matching result to obtain a text matching model, and the actual matching result includes the target search type corresponding to the query sample.
[0131] Optionally, in some embodiments, "based on the query sample feature, the content sample feature and the initial search type feature, the query sample is matched with the content sample to obtain a predicted matching result". Specifically, the sample association information between the query sample and the content sample can be determined, and the sample association information can be converted into features to obtain sample association features; the query sample feature and the associated sample feature are concatenated to obtain a first concatenated feature, and the content feature and the associated feature are concatenated to obtain a second concatenated feature; based on the first concatenated feature, the second concatenated feature and the initial search type feature, the query sample is matched with the content sample to obtain a predicted matching result.
[0132] Optionally, in some embodiments, "based on the first splicing feature, the second splicing feature and the initial search type feature, the query sample is matched with the content sample to obtain a predicted matching result". Specifically, the first splicing feature and the initial search type feature corresponding to each preset search type can be added together to obtain at least one fused sample feature; the similarity between each fused sample feature and the second splicing feature is calculated respectively, and the predicted matching result is determined based on the calculation result.
[0133] Optionally, in some embodiments, "the similarity between each fused sample feature and the second spliced feature is calculated separately, and the predicted matching result is determined based on the calculation result". Specifically, the similarity between each fused sample feature and the second spliced feature can be calculated separately to obtain similarity results between the query sample and the content sample in each preset search type; based on the similarity results, the predicted search type of the query sample and the content sample is determined, and the predicted search type and the similarity results corresponding to the predicted search type are used as predicted matching results.
[0134] As can be seen from the above, this embodiment can obtain a query text and a content text searched based on the query text; then, feature extraction is performed on the query text and the content text respectively to obtain a query feature corresponding to the query text and a content feature corresponding to the content text; then, the association information between the query text and the content text is determined, and the association information is converted to obtain an association feature; then, the query feature and the association feature are fused to obtain a first fusion feature, and the content feature and the association feature are fused to obtain a second fusion feature; then, a search type feature is obtained, and based on the first fusion feature, the second fusion feature and the search type feature, the query text is matched with the content text to obtain a matching result. Since the scheme obtains the statistical matching feature of text matching by determining the association information between the query text and the content text, and then the statistical matching feature is fused with the semantic feature of the text, some common matching errors caused by using only the semantic model are overcome, and by classifying the search tasks and constructing multi-type text matching, the task-related prior knowledge is fused with the semantic representation, which greatly improves the accuracy of text matching. This solution enhances the statistical features between query and doc by using BM25 features, greatly enriches its semantic features by adding features that enter the statistical dimension into the semantic model, and explicitly integrates different search types into the model, enhancing the unity and uniqueness of different types of semantic discrimination. Because this solution considers the semantic and statistical dimensions of the text through multi-dimensional feature fusion, the feature information of text matching is more sufficient, the consideration is more comprehensive, and the matching results are more prepared, which greatly improves the accuracy of text matching and further improves the efficiency of content text screening.
[0135] According to the method described in the previous embodiment, an example is given below to further illustrate it in detail.
[0136] In this embodiment, the text matching device is specifically integrated into an electronic device as an example for description.
[0137] (I) First, the preset text model can be trained as follows:
[0138] In order to improve the efficiency of text matching, the preset text matching model is first trained, and then the trained text matching model is used to perform text matching on the query text and the content text. Optionally, the text matching model can be trained by multiple training samples. Specifically, it can be trained by other devices and then provided to the electronic device, or it can also be trained by the electronic device itself.
[0139] For example, the preset search types may include question-answer search type, topic search type, and interpretation search type. Then, the query samples and content samples corresponding to the query samples in the training sample set are classified to determine which of the three types their search types belong to. The training sample set and the determined search type are then used to train the preset text matching model.
[0140] For example, the electronic device can specifically obtain a training sample set, which includes at least one query sample and a content sample searched based on the query sample; and obtain at least one preset search type, and classify the query sample based on the preset search type to obtain a target search type corresponding to the query sample.
[0141] For example, the training data of search matching text can be classified into question-answer search, topic search, and interpretation search to obtain the following data samples: D = {(s i ,r k ,s j )}, where s i and j Represents the contents of query and doc respectively, r k Indicates the search type of query and doc.
[0142] Next, the electronic device can use the preset text matching model to extract features from the query sample and the content sample respectively, to obtain query sample features and content sample features; and initialize the features of the preset search type to obtain initial search type features. For example, the query sample features extracted from the query sample query can be recorded as EmbeddingA, and the content sample features extracted from the content sample doc can be recorded as Embedding B. Three Embedding vectors are initialized for the three types of question-and-answer search type, topic search type, and interpretation search type, namely r1, r2, and r3.
[0143] Then, the electronic device can determine the sample association information between the query sample and the content sample, and perform feature conversion on the sample association information to obtain sample association features. For example, the electronic device can specifically perform morpheme analysis on the query sample to obtain at least one query morpheme; calculate the correlation between each query morpheme and the content sample to obtain a morpheme correlation score; determine the weight of each query morpheme, and perform weighted processing on the morpheme correlation score based on the weight to obtain association information between the query sample and the content sample. The association information is normalized to obtain processed association information; based on the dimension of the query sample feature, the processed association information is dimensionally expanded to obtain sample association features.
[0144] For example, BM25 can be used to calculate the sample association information between the query sample and the content sample to obtain the correlation score, and then the BM25 score is normalized, and then the normalized BM25 score is expanded to make it become the feature of the Embedding A dimension to obtain the sample association feature. For example, BM25 can be used to perform morpheme analysis on the query to generate the morpheme q i ; Then, for each search result Doc, calculate each morpheme q i The correlation score with Doc, finally, q i The relevance score of Query and Doc is obtained by weighted summation relative to the relevance score of Doc. The calculation formula can be as follows:
[0145]
[0146] Where k1 and b are adjustment factors, fi is the frequency of qi in d, and qfi is the frequency of qi in Query. dl is the length of content sample d, and avgdl is the average length of all content samples. n(qi) is the number of texts containing qi.
[0147] Since the BM25 score has no upper limit, it can be normalized to obtain an explainable score for a given query sample and content sample. For example, it can be normalized as follows:
[0148]
[0149] Among them, the numerator is the BM25 score of the current query-doc, and the numerator is the sum of the BM25 scores of all docs to be calculated under the query.
[0150] Next, the normalized BM25 score can be expanded to have the same dimensions as the query sample features and content sample features, as follows:
[0151]
[0152] Among them, W bm25 Refers to the dimension of the query feature.
[0153] Therefore, the bm25 score between query and doc can obtain its Embedding C (i.e., sample association feature) representation.
[0154] Next, the electronic device may splice the query sample feature and the associated sample feature to obtain a first spliced feature, and splice the content feature and the associated feature to obtain a second spliced feature.
[0155] For example, the query's Embedding A and Embedding C can be concatenated to obtain E1 (i.e., the first concatenated feature), and the doc's Embedding B and Embedding C can be concatenated to obtain E2 (i.e., the second concatenated feature).
[0156] Then, the electronic device can add the first splicing feature and the initial search type feature corresponding to each preset search type to obtain at least one fused sample feature; calculate the similarity between each fused sample feature and the second splicing feature to obtain the similarity results of the query sample and the content sample in each preset search type. Based on the similarity results, the predicted search types of the query sample and the content sample are determined, and the predicted search type and the similarity results corresponding to the predicted search type are used as predicted matching results, and the predicted matching results include the predicted search type corresponding to the query sample.
[0157] For example, when obtaining each similarity distance, the task embedding can be added to the sentence representation, thereby integrating the task-related prior knowledge with the semantic representation. The final distance calculation uses cosin similarity as follows:
[0158] distance=cosin(E1+r i ,E2)
[0159] When the model predicts, the cosine distance between E1 and E2 after the three vectors are superimposed will be calculated in turn, and the one with the largest value will be selected to obtain the similarity score as the similarity result. Then this similarity score and the search type corresponding to this similarity score will be used as the predicted matching result.
[0160] Finally, the electronic device can use the predicted matching results and the actual matching results to converge the preset text matching model to obtain a text matching model, and the actual matching results include the target search type corresponding to the query sample.
[0161] For example, the loss used in model training can be:
[0162] loss=1-distance
[0163] (II) Using the trained text matching model, the query text and content text can be matched. For details, please refer to Figure 3 and Figure 4 .
[0164] like Figure 3 As shown, a text matching method, the specific process can be as follows:
[0165] 201. An electronic device obtains a query text and a content text searched based on the query text.
[0166] For example, when receiving a text matching request, the electronic device can obtain the query text according to the text matching request. For example, when text matching is required, a text matching request can be generated and sent to the electronic device, so that the electronic device can obtain the query text, and use the obtained query text to search to obtain the content text, and then match the query text with the content text to generate a matching result, and then the matching result can be sorted and displayed, etc. Figure 4 As shown, the query text may be "What is a certain red book?" and the content text may be "A certain red book is a ****** mobile phone application."
[0167] 202. The electronic device extracts features from the query text and the content text respectively to obtain query features corresponding to the query text and content features corresponding to the content text.
[0168] After obtaining the query text and the content text, the query text and the content text may be subjected to feature extraction. For example, the electronic device may specifically use a text matching model to extract features from the query text to obtain query features; and use a text matching model to extract features from the content text to obtain content features. Figure 4 As shown, the query text can be sentence encoded for feature extraction, and the content text can be sentence encoded for feature extraction, and weights can be shared. The extracted query features can be recorded as Embedding A, and the content features can be recorded as Embedding B.
[0169] 203. The electronic device determines association information between the query text and the content text.
[0170] For example, the electronic device may specifically perform morpheme analysis on the query text to obtain at least one query morpheme; calculate the correlation between each query morpheme and the content text to obtain a morpheme correlation score; determine the weight of each query morpheme, and perform weighted processing on the morpheme correlation score based on the weight to obtain the association information between the query text and the content text. Figure 4 As shown, BM25 between query and doc can be calculated.
[0171] 204. The electronic device performs feature conversion on the associated information to obtain associated features.
[0172] For example, the electronic device may specifically normalize the associated information to obtain processed associated information; and based on the dimension of the query feature, perform dimension expansion on the processed associated information to obtain associated features. Figure 4 As shown, the associated feature can be recorded as Embedding C.
[0173] 205. The electronic device fuses the query feature and the associated feature to obtain a first fused feature, and fuses the content feature and the associated feature to obtain a second fused feature.
[0174] For example, the electronic device may specifically perform feature splicing on the query feature and the associated feature to obtain a first fused feature, such as E1; and perform feature splicing on the content feature and the associated feature to obtain a second fused feature, such as E2.
[0175] 206. The electronic device obtains a search type feature, and matches the query text with the content text based on the first fusion feature, the second fusion feature, and the search type feature to obtain a matching result.
[0176] For example, the electronic device can specifically obtain a preset search type in a text matching model, and determine the search type features corresponding to the preset search types based on the text matching model, such as r1, r2, and r3; respectively add the first fused feature to the search type features corresponding to each preset search type to obtain at least one fused feature; respectively calculate the similarity between each fused feature and the second fused feature to obtain similarity information between the query text and the content text in each preset search type; determine the current search type of the query text and the content text based on the similarity information, and use the current search type and the similarity information corresponding to the current search type as the matching result.
[0177] Since the general text matching model structure is relatively simple, it does not take into account different types of search requirements in search scenarios, and the performance of purely semantic models is also insufficient. Therefore, we can add fine-grained relationship similarity scores of sentence pairs to the text matching model to decompose the text matching requirements in different types of search scenarios, and also integrate the statistical matching scores between query and doc into the overall text matching model to enhance the generalization performance of the text matching model.
[0178] As can be seen from the above, this embodiment can obtain a query text and a content text searched based on the query text; then, feature extraction is performed on the query text and the content text respectively to obtain a query feature corresponding to the query text and a content feature corresponding to the content text; then, the association information between the query text and the content text is determined, and the association information is converted to obtain an association feature; then, the query feature and the association feature are fused to obtain a first fusion feature, and the content feature and the association feature are fused to obtain a second fusion feature; then, a search type feature is obtained, and based on the first fusion feature, the second fusion feature and the search type feature, the query text is matched with the content text to obtain a matching result. Since the scheme obtains the statistical matching feature of text matching by determining the association information between the query text and the content text, and then the statistical matching feature is fused with the semantic feature of the text, some common matching errors caused by using only the semantic model are overcome, and by classifying the search tasks and constructing multi-type text matching, the task-related prior knowledge is fused with the semantic representation, which greatly improves the accuracy of text matching. This solution enhances the statistical features between query and doc by using BM25 features, greatly enriches its semantic features by adding features that enter the statistical dimension into the semantic model, and explicitly integrates different search types into the model, enhancing the unity and uniqueness of different types of semantic discrimination. Because this solution considers the semantic and statistical dimensions of the text through multi-dimensional feature fusion, the feature information of text matching is more sufficient, the consideration is more comprehensive, and the matching results are more prepared, which greatly improves the accuracy of text matching and further improves the efficiency of content text screening.
[0179] In order to better implement the above method, accordingly, the embodiment of the present application also provides a text matching device, which can be specifically integrated in an electronic device, and the electronic device can be a server, a terminal or other devices.
[0180] For example, Figure 5 As shown, the text matching device may include an acquisition unit 301, an extraction unit 302, a conversion unit 303, a fusion unit 304 and a matching unit 305, as follows:
[0181] An acquisition unit 301 is used to acquire a query text and a content text searched based on the query text;
[0182] An extraction unit 302 is used to extract features from the query text and the content text respectively to obtain query features corresponding to the query text and content features corresponding to the content text;
[0183] The conversion unit 303 is used to determine the correlation information between the query text and the content text, and perform feature conversion on the correlation information to obtain correlation features;
[0184] A fusion unit 304 is used to fuse the query feature and the associated feature to obtain a first fused feature, and to fuse the content feature and the associated feature to obtain a second fused feature;
[0185] The matching unit 305 is used to obtain a search type feature, and match the query text with the content text based on the first fusion feature, the second fusion feature and the search type feature to obtain a matching result.
[0186] Optionally, in some embodiments, Figure 6 As shown, the conversion unit 303 includes an association subunit 3031 and a conversion subunit 3032, as follows:
[0187] The association subunit 3031 can be specifically used to perform morpheme analysis on the query text to obtain at least one query morpheme; calculate the correlation between each query morpheme and the content text to obtain a morpheme correlation score; determine the weight of each query morpheme, and perform weighted processing on the morpheme correlation score based on the weight to obtain association information between the query text and the content text.
[0188] Optionally, in some embodiments, the conversion subunit 3032 can be specifically used to normalize the association information to obtain processed association information; based on the dimension of the query feature, perform dimension expansion on the processed association information to obtain association features.
[0189] Optionally, in some embodiments, the fusion unit 304 may be specifically configured to perform feature splicing on the query feature and the associated feature to obtain a first fused feature; and perform feature splicing on the content feature and the associated feature to obtain a second fused feature.
[0190] Optionally, in some embodiments, the matching unit 305 can be specifically used to obtain at least one preset search type, determine the search type feature corresponding to the preset search type based on a text matching model; add the first fusion feature and the search type feature to obtain a fused feature; and determine the matching result between the query text and the content text based on similarity information between the fused feature and the second fusion feature.
[0191] Optionally, in some embodiments, the matching unit 305 can be specifically used to add the first fused feature and the search type feature corresponding to each preset search type, respectively, to obtain at least one fused feature; respectively calculate the similarity between each fused feature and the second fused feature, to obtain similarity information between the query text and the content text in each preset search type; determine the current search type of the query text and the content text based on the similarity information, and take the current search type and the similarity information corresponding to the current search type as the matching result.
[0192] Optionally, in some embodiments, Figure 7 As shown, the text matching device may further include a training unit 306, and the training unit 306 may include an acquisition subunit 3061 and a training subunit 3062, as follows:
[0193] The acquisition subunit 3061 may be specifically used to acquire a training sample set, the training sample set including at least one query sample and a content sample searched based on the query sample; acquire at least one preset search type, and classify the query sample based on the preset search type to obtain a target search type corresponding to the query sample;
[0194] The training subunit 3062 may be specifically configured to train a preset text matching model using the training sample set and the target search type to obtain a text matching model.
[0195] Optionally, in some embodiments, the training subunit 3062 can be specifically used to use a preset text matching model to extract features from the query sample and the content sample respectively to obtain query sample features and content sample features; perform feature initialization on the preset search type to obtain initial search type features; match the query sample with the content sample based on the query sample features, the content sample features and the initial search type features to obtain a predicted matching result, wherein the predicted matching result includes the predicted search type corresponding to the query sample; use the predicted matching result and the actual matching result to converge the preset text matching model to obtain a text matching model, wherein the actual matching result includes the target search type corresponding to the query sample.
[0196] Optionally, in some embodiments, the training subunit 3062 can be specifically used to determine the sample association information between the query sample and the content sample, and perform feature conversion on the sample association information to obtain sample association features; splice the query sample features and the associated sample features to obtain a first spliced feature, and splice the content features and the associated features to obtain a second spliced feature; based on the first spliced feature, the second spliced feature and the initial search type feature, match the query sample with the content sample to obtain a predicted matching result.
[0197] Optionally, in some embodiments, the training subunit 3062 can be specifically used to add the first splicing feature and the initial search type feature corresponding to each preset search type, respectively, to obtain at least one fused sample feature; respectively calculate the similarity between each fused sample feature and the second splicing feature, and determine the predicted matching result based on the calculation result.
[0198] Optionally, in some embodiments, the training subunit 3062 can be specifically used to calculate the similarity between each fused sample feature and the second spliced feature, respectively, to obtain similarity results between the query sample and the content sample in each preset search type; based on the similarity results, the predicted search type of the query sample and the content sample is determined, and the predicted search type and the similarity results corresponding to the predicted search type are used as predicted matching results.
[0199] In specific implementation, the above units can be implemented as independent entities, or can be arbitrarily combined to be implemented as the same or several entities. The specific implementation of the above units can refer to the previous method embodiments, which will not be repeated here.
[0200] As can be seen from the above, in this embodiment, the acquisition unit 301 can acquire the query text and the content text searched based on the query text; then, the extraction unit 302 performs feature extraction on the query text and the content text respectively to obtain the query feature corresponding to the query text and the content feature corresponding to the content text; then, the conversion unit 303 determines the association information between the query text and the content text, and performs feature conversion on the association information to obtain the association feature; then, the fusion unit 304 fuses the query feature and the association feature to obtain the first fusion feature, and fuses the content feature and the association feature to obtain the second fusion feature; then, the matching unit 305 acquires the search type feature, and matches the query text with the content text based on the first fusion feature, the second fusion feature and the search type feature to obtain a matching result. Since the scheme obtains the statistical matching features of text matching by determining the association information between the query text and the content text, and then fuses the statistical matching features with the semantic features of the text, it overcomes some common matching errors caused by using only the semantic model, and by classifying the search tasks and constructing multiple types of text matching, it fuses the task-related prior knowledge with the semantic representation, greatly improving the accuracy of text matching. This scheme greatly enriches its semantic features by adding features that enter the statistical dimension to the semantic model, and explicitly integrates different search types into the model, enhancing the unity and uniqueness of different types of semantic discrimination. Since this scheme considers the semantic and statistical dimensions of the text through multi-dimensional feature fusion, the feature information of text matching is more sufficient, the consideration is more comprehensive, and the matching results are more prepared, which greatly improves the accuracy of text matching and further improves the efficiency of content text screening.
[0201] In addition, the present application also provides an electronic device, such as Figure 8 As shown, it shows a schematic diagram of the structure of the electronic device involved in the embodiment of the present application, specifically:
[0202] The electronic device may include components such as a processor 401 with one or more processing cores, a memory 402 with one or more computer-readable storage media, a power supply 403, and an input unit 404. Those skilled in the art will appreciate that Figure 8 The electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0203] The processor 401 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 402, and calling data stored in the memory 402, the processor 401 performs various functions of the electronic device and processes data. Optionally, the processor 401 may include one or more processing cores; preferably, the processor 401 may integrate an application processor and a modem processor, wherein the application processor mainly processes the operating system, user interface, and application programs, and the modem processor mainly processes wireless communications. It is understandable that the above-mentioned modem processor may not be integrated into the processor 401.
[0204] The memory 402 can be used to store software programs and modules. The processor 401 executes various functional applications and data processing by running the software programs and modules stored in the memory 402. The memory 402 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 402 may also include a memory controller to provide the processor 401 with access to the memory 402.
[0205] The electronic device also includes a power supply 403 for supplying power to each component. Preferably, the power supply 403 can be logically connected to the processor 401 through a power management system, so as to manage charging, discharging, power consumption and other functions through the power management system. The power supply 403 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators and other arbitrary components.
[0206] The electronic device may further include an input unit 404, which may be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal input related to user settings and function control.
[0207] Although not shown, the electronic device may further include a display unit, etc., which will not be described in detail herein. Specifically in this embodiment, the processor 401 in the electronic device will load the executable files corresponding to the processes of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application programs stored in the memory 402, thereby realizing various functions, as follows:
[0208] A query text and a content text searched based on the query text are obtained; then, feature extraction is performed on the query text and the content text respectively to obtain query features corresponding to the query text and content features corresponding to the content text; then, association information between the query text and the content text is determined, and feature conversion is performed on the association information to obtain association features; then, the query features and the association features are fused to obtain a first fused feature, and the content features and the association features are fused to obtain a second fused feature; then, a search type feature is obtained, and based on the first fused feature, the second fused feature and the search type feature, the query text is matched with the content text to obtain a matching result.
[0209] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0210] As can be seen from the above, this embodiment can obtain a query text and a content text searched based on the query text; then, feature extraction is performed on the query text and the content text respectively to obtain a query feature corresponding to the query text and a content feature corresponding to the content text; then, the association information between the query text and the content text is determined, and the association information is converted to obtain an association feature; then, the query feature and the association feature are fused to obtain a first fusion feature, and the content feature and the association feature are fused to obtain a second fusion feature; then, a search type feature is obtained, and based on the first fusion feature, the second fusion feature and the search type feature, the query text is matched with the content text to obtain a matching result. Since the scheme obtains the statistical matching feature of text matching by determining the association information between the query text and the content text, and then the statistical matching feature is fused with the semantic feature of the text, some common matching errors caused by using only the semantic model are overcome, and by classifying the search tasks and constructing multi-type text matching, the task-related prior knowledge is fused with the semantic representation, which greatly improves the accuracy of text matching. This solution greatly enriches the semantic features by adding features that enter the statistical dimension into the semantic model, and explicitly integrates different search types into the model, enhancing the unity and uniqueness of different types of semantic discrimination. Because this solution considers the semantic and statistical dimensions of the text through multi-dimensional feature fusion, the feature information of text matching is more sufficient, the consideration is more comprehensive, and the matching results are more prepared, which greatly improves the accuracy of text matching and further improves the efficiency of content text screening.
[0211] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0212] To this end, the embodiment of the present application further provides a storage medium in which a plurality of instructions are stored, and the instructions can be loaded by a processor to execute the steps in any text matching method provided in the embodiment of the present application. For example, the instructions can execute the following steps:
[0213] A query text and a content text searched based on the query text are obtained; then, feature extraction is performed on the query text and the content text respectively to obtain query features corresponding to the query text and content features corresponding to the content text; then, association information between the query text and the content text is determined, and feature conversion is performed on the association information to obtain association features; then, the query features and the association features are fused to obtain a first fused feature, and the content features and the association features are fused to obtain a second fused feature; then, a search type feature is obtained, and based on the first fused feature, the second fused feature and the search type feature, the query text is matched with the content text to obtain a matching result.
[0214] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0215] The storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0216] Since the instructions stored in the storage medium can execute the steps in any text matching method provided in the embodiments of the present application, the beneficial effects that can be achieved by any text matching method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0217] The above is a detailed introduction to a text matching method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A text matching method, It is characterized in that include: Obtaining a query text and a content text searched based on the query text; Performing feature extraction on the query text and the content text respectively to obtain query features corresponding to the query text and content features corresponding to the content text; Calculating the correlation between the query text and the content text, and determining association information between the query text and the content text according to the correlation; Performing feature conversion on the associated information to obtain associated features; The query feature and the associated feature are fused to obtain a first fused feature, and the content feature and the associated feature are fused to obtain a second fused feature; A search type feature is obtained, and based on the first fusion feature, the second fusion feature and the search type feature, the query text is matched with the content text to obtain a matching result.
2. The method according to claim 1, It is characterized in that The calculating the correlation between the query text and the content text, and determining the association information between the query text and the content text according to the correlation, includes: Performing morpheme analysis on the query text to obtain at least one query morpheme; Calculating the correlation between each query morpheme and the content text to obtain a morpheme correlation score; The weight of each query morpheme is determined, and the morpheme relevance scores are weighted based on the weight to obtain association information between the query text and the content text.
3. The method according to claim 1, It is characterized in that The performing feature conversion on the associated information to obtain associated features includes: Normalizing the associated information to obtain processed associated information; Based on the dimension of the query feature, the processed association information is dimensionally expanded to obtain the association feature.
4. The method according to claim 1, It is characterized in that The step of fusing the query feature with the association feature to obtain a first fused feature, and fusing the content feature with the association feature to obtain a second fused feature includes: Perform feature concatenation on the query feature and the associated feature to obtain a first fusion feature; The content feature and the associated feature are concatenated to obtain a second fused feature.
5. The method according to any one of claims 1 to 4, It is characterized in that The acquiring the search type feature, matching the query text with the content text based on the first fusion feature, the second fusion feature and the search type feature to obtain a matching result, includes: Obtain at least one preset search type, and determine a search type feature corresponding to the preset search type based on a text matching model, wherein the text matching model is a trained model; Adding the first fusion feature and the search type feature to obtain a fused feature; Based on the similarity information between the fused feature and the second fused feature, a matching result between the query text and the content text is determined.
6. The method according to claim 5, It is characterized in that The adding the first fusion feature and the search type feature to obtain a fused feature includes: Respectively adding the first fusion feature to the search type feature corresponding to each preset search type to obtain at least one fused feature; The determining, based on the similarity between the fused feature and the second fused feature, a matching result between the query text and the content text includes: Calculating the similarity between each fused feature and the second fused feature respectively, and obtaining similarity information between the query text and the content text in each preset search type; The current search type of the query text and the content text is determined based on the similar information, and the current search type and the similar information corresponding to the current search type are used as matching results.
7. The method according to claim 5, It is characterized in that Before obtaining at least one preset search type and determining the search type feature corresponding to the preset search type based on the text matching model, the method further includes: Acquire a training sample set, wherein the training sample set includes at least one query sample and a content sample searched based on the query sample; Obtain at least one preset search type, and classify the query sample based on the preset search type to obtain a target search type corresponding to the query sample; The preset text matching model is trained using the training sample set and the target search type to obtain a text matching model.
8. The method according to claim 7, It is characterized in that The method of training a preset text matching model by using the training sample set and the target search type to obtain a text matching model includes: Using a preset text matching model to extract features from the query sample and the content sample respectively, to obtain query sample features and content sample features; Initializing the features of the preset search type to obtain initial search type features; Based on the query sample feature, the content sample feature and the initial search type feature, the query sample is matched with the content sample to obtain a predicted matching result, wherein the predicted matching result includes a predicted search type corresponding to the query sample; The preset text matching model is converged using the predicted matching result and the actual matching result to obtain a text matching model, wherein the actual matching result includes the target search type corresponding to the query sample.
9. The method according to claim 8, It is characterized in that The matching the query sample with the content sample based on the query sample feature, the content sample feature and the initial search type feature to obtain a predicted matching result includes: Determining sample association information between the query sample and the content sample, and performing feature conversion on the sample association information to obtain sample association features; The query sample feature and the sample association feature are spliced to obtain a first spliced feature, and the content feature and the association feature are spliced to obtain a second spliced feature; Based on the first splicing feature, the second splicing feature and the initial search type feature, the query sample is matched with the content sample to obtain a predicted matching result.
10. The method according to claim 9, It is characterized in that The step of matching the query sample with the content sample based on the first splicing feature, the second splicing feature and the initial search type feature to obtain a predicted matching result includes: Respectively adding the first concatenated feature and the initial search type feature corresponding to each preset search type to obtain at least one fused sample feature; The similarity between each fused sample feature and the second splicing feature is calculated respectively, and a predicted matching result is determined based on the calculation result.
11. The method according to claim 10, It is characterized in that The respectively calculating the similarity between each fused sample feature and the second splicing feature, and determining the predicted matching result based on the calculation result, includes: Calculating the similarity between each fused sample feature and the second spliced feature respectively, and obtaining similarity results between the query sample and the content sample in each preset search type; The predicted search types of the query sample and the content sample are determined based on the similar results, and the predicted search type and the similar results corresponding to the predicted search type are used as predicted matching results.
12. A text matching device, It is characterized in that include: An acquisition unit, used to acquire a query text and a content text searched based on the query text; An extraction unit, used to extract features from the query text and the content text respectively, to obtain query features corresponding to the query text and content features corresponding to the content text; A conversion unit, used to calculate the correlation between the query text and the content text, and determine the association information between the query text and the content text according to the correlation; perform feature conversion on the association information to obtain association features; A fusion unit, configured to fuse the query feature and the associated feature to obtain a first fused feature, and to fuse the content feature and the associated feature to obtain a second fused feature; The matching unit is used to obtain a search type feature, and match the query text with the content text based on the first fusion feature, the second fusion feature and the search type feature to obtain a matching result.
13. An electronic device, It is characterized in that The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps in the text matching method according to any one of claims 1 to 11 are implemented.
14. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the text matching method according to any one of claims 1 to 11.
