A text sorting method and device
The text sorting method enhances semantic search accuracy by employing initial word sense similarity and target sorting with a deep learning model, addressing the mismatch in existing systems by aligning text domains with user intent.
Patent Information
- Application Number
- CN202111254933.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2041-10-27
AI Technical Summary
Existing text sorting methods in semantic search systems suffer from inaccurate sorting results due to the lack of consideration for semantic information between recommended texts, leading to a mismatch between the user's search intent and the sorting outcomes.
A text sorting method that involves initial sorting based on word sense similarity and subsequent target sorting using a trained deep learning model to enhance semantic similarity, dividing texts into multiple domains and adjusting weights accordingly.
Improves the accuracy and efficiency of text sorting by better reflecting the relevance between the main content of recommended texts and search terms, ensuring the sorting results align more closely with user intent.
Smart Images

Figure CN113987161B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence technology and discloses a text sorting method and device. Background Art
[0002] Semantic search is to filter out a limited set of texts that meet the search intent from a massive text set and display them to users in an orderly manner. It also has high requirements on the response speed of online search engines, generally in milliseconds.
[0003] At present, the commonly used text sorting methods are mainly: based on the search terms input by the user, using the inverted text index method, matching multiple recommended texts related to the search terms from the original text collection, using the search engine's own sorting algorithm, calculating the relevance score between the keywords in each recommended text and the search terms, and sorting multiple search texts according to the scores.
[0004] The search engine's built-in sorting algorithm analyzes the recommended text as a whole when calculating the correlation between words, resulting in inaccurate calculation of word meaning similarity, which in turn affects the sorting results; moreover, the word meaning similarity between the search term and the keyword only reflects the shallow association between the search text and the recommended text, and the sorting is based on the correlation score between the search term and the keyword, resulting in low accuracy of the sorting results. Summary of the invention
[0005] The embodiments of the present application provide a text sorting method and device to improve the accuracy and efficiency of text sorting.
[0006] In a first aspect, an embodiment of the present application provides a text sorting method, the method comprising:
[0007] In response to a search request sent by a target object, a plurality of recommended texts are screened out from an original text set according to at least one search term in a search text carried in the search request;
[0008] Determining the semantic similarity between the search text and each recommended text according to the word frequency of the at least one search word in each preset text field of each recommended text and the weight corresponding to the preset text field;
[0009] Perform initial sorting of each recommended text based on multiple word meaning similarities;
[0010] According to the semantic information between the recommended texts, the trained target text sorting model is used to perform target sorting on the recommended texts after the initial sorting.
[0011] Optionally, each of the preset text fields includes at least a subject field, a keyword field, and a statistics field, and each of the preset text fields is determined in the following manner:
[0012] Using the trained topic model, label each recommended text with a topic label to obtain the topic domain of each recommended text; and
[0013] According to the pre-generated keyword word library, each recommended text is segmented, and the keyword domain of each recommended text is generated according to the keywords in each recommended text and the information entropy of the corresponding recommended text; and
[0014] According to the text length of each recommended text, a statistical domain of each recommended text is generated.
[0015] Optionally, the calculation formula for the semantic similarity between the search text and a recommended text is as follows:
[0016]
[0017]
[0018]
[0019] Among them, q i represents the i-th search term in the search text, d i represents a recommended text related to the i-th search term, 0.5 is the training coefficient, N is the total number of recommended texts, O is the total number of recommended texts related to each search term, and n i is the total number of recommended texts corresponding to the i-th search term, r i is the number of recommended texts related to the i-th search term, k1 is the adjustment factor, u is the number of preset document domains in a recommended text, and w k is the weight corresponding to the kth preset document domain, f ui is the frequency of the ith search term in the preset document domain, f i u is the total frequency of the ith search term in the preset document domain, B u The length of the preset document domain, ul u The actual length of each preset document field, uvul u is the average length of each preset document domain, b u Length adjustment factor for each preset document field.
[0020] Optionally, the step of using a trained target sorting model to perform target sorting on the recommended texts after the initial sorting according to the semantic information between the recommended texts includes:
[0021] According to the feature vectors of the recommended texts after the initial sorting and the bidirectional semantic information between the recommended texts after the initial sorting, the recommended texts after the initial sorting are respectively encoded to obtain the encoding vectors of the recommended texts after the initial sorting;
[0022] A multi-head attention mechanism is used to adjust the encoding vectors of each recommended text after the initial sorting and perform regularization representation;
[0023] Determining a set of truncation positions of each recommended text after initial sorting according to the encoding vector of each recommended text after regularization representation, and determining the probability of each truncation position in the set of truncation positions;
[0024] According to the probability of each truncation position, each recommended text after the initial sorting is targeted and sorted.
[0025] Optionally, the feature vectors of the recommended texts after the initial sorting are determined in the following manner:
[0026] For one of the recommended texts after the initial sorting:
[0027] Using the semantic similarity between the search text and the one recommended text as a first feature vector of the one recommended text;
[0028] Calculating the semantic similarity between the one recommended text and an adjacent recommended text;
[0029] generating a second feature vector of the recommended text according to the basic features of the recommended text and the corresponding semantic similarity;
[0030] The first feature vector and the second feature vector are concatenated to obtain a feature vector of the recommended text.
[0031] Optionally, the multi-head attention mechanism is used to adjust the encoding vectors of each recommended text after the initial sorting, including:
[0032] For one of the recommended texts after the initial sorting:
[0033] Calculating the semantic similarity between the one recommended text and N-1 recommended texts respectively, where N is the total number of the multiple recommended texts;
[0034] Determining an attention coefficient corresponding to the recommended text according to N-1 semantic similarities corresponding to the recommended text;
[0035] According to the attention coefficient, the encoding vector of the recommended text is adjusted, and the adjusted encoding vector is regularized.
[0036] Optionally, the target text sorting model is trained in the following way:
[0037] Get a training sample set;
[0038] Based on the training sample set, the text sorting model to be trained is trained multiple times iteratively to obtain a target text recommendation model, wherein in each iteration process, the following operations are performed:
[0039] Inputting multiple recommended text samples in the training sample set and the true label of each recommended text sample into the text sorting model to be trained, and processing the feature vectors of the multiple recommended text samples by the text sorting model to be trained to obtain a predicted label corresponding to each recommended text sample; wherein the true label is used to characterize the semantic similarity between the recommended text sample and the corresponding search text;
[0040] Determining predicted cutoff positions of the plurality of recommended text samples according to the predicted label corresponding to each recommended text sample;
[0041] Determining a predicted truncation loss value of the predicted truncation position according to the true label;
[0042] According to the predicted truncation loss value, parameters of the text sorting model to be trained are adjusted.
[0043] In a second aspect, an embodiment of the present application provides a text sorting device, comprising:
[0044] A response module, configured to respond to a search request sent by a target object and filter out a plurality of recommended texts from an original text set according to at least one search term in a search text carried in the search request;
[0045] A similarity calculation module, configured to determine the semantic similarity between the search text and each recommended text according to the frequency of the at least one search word in each preset text field of each recommended text and the weight corresponding to the preset text field;
[0046] A first sorting module, used for initially sorting each recommended text according to multiple word meaning similarities;
[0047] The second sorting module is used to perform target sorting on the recommended texts after the initial sorting according to the semantic information between the recommended texts using the trained target text sorting model.
[0048] Optionally, a text domain division module is also included, which is used to:
[0049] Using the trained topic model, label each recommended text with a topic label to obtain the topic domain of each recommended text; and
[0050] According to the pre-generated keyword word library, each recommended text is segmented, and the keyword domain of each recommended text is generated according to the keywords in each recommended text and the information entropy of the corresponding recommended text; and
[0051] According to the text length of each recommended text, a statistical domain of each recommended text is generated.
[0052] Optionally, the calculation formula for the semantic similarity between the search text and a recommended text is as follows:
[0053]
[0054]
[0055]
[0056] Among them, q i represents the i-th search term in the search text, d i represents a recommended text related to the i-th search term, 0.5 is the training coefficient, N is the total number of recommended texts, O is the total number of recommended texts related to each search term, and n i is the total number of recommended texts corresponding to the i-th search term, r i is the number of recommended texts related to the i-th search term, k1 is the adjustment factor, u is the number of preset document domains in a recommended text, and w k is the weight corresponding to the kth preset document domain, f ui is the frequency of the ith search term in the preset document domain, f i u is the total frequency of the ith search term in the preset document domain, B u The length of the preset document domain, ul u The actual length of each preset document field, uvul u is the average length of each preset document domain, b u Length adjustment factor for each preset document field.
[0057] Optionally, the second sorting module is specifically used to:
[0058] According to the feature vectors of the recommended texts after the initial sorting and the bidirectional semantic information between the recommended texts after the initial sorting, the recommended texts after the initial sorting are respectively encoded to obtain the encoding vectors of the recommended texts after the initial sorting;
[0059] A multi-head attention mechanism is used to adjust the encoding vectors of each recommended text after the initial sorting and perform regularization representation;
[0060] Determining a set of truncation positions of each recommended text after initial sorting according to the encoding vector of each recommended text after regularization representation, and determining the probability of each truncation position in the set of truncation positions;
[0061] According to the probability of each truncation position, each recommended text after the initial sorting is targeted and sorted.
[0062] Optionally, the second sorting module is specifically used to:
[0063] For one of the recommended texts after the initial sorting:
[0064] Using the semantic similarity between the search text and the one recommended text as a first feature vector of the one recommended text;
[0065] Calculating the semantic similarity between the one recommended text and an adjacent recommended text;
[0066] generating a second feature vector of the recommended text according to the basic features of the recommended text and the corresponding semantic similarity;
[0067] The first feature vector and the second feature vector are concatenated to obtain a feature vector of the recommended text.
[0068] Optionally, the second sorting module is specifically used to:
[0069] For one of the recommended texts after the initial sorting:
[0070] Calculating the semantic similarity between the one recommended text and N-1 recommended texts respectively, where N is the total number of the multiple recommended texts;
[0071] Determining an attention coefficient corresponding to the recommended text according to N-1 semantic similarities corresponding to the recommended text;
[0072] According to the attention coefficient, the encoding vector of the recommended text is adjusted, and the adjusted encoding vector is regularized.
[0073] Optionally, a training module is also included to:
[0074] Get a training sample set;
[0075] Based on the training sample set, the text sorting model to be trained is trained multiple times iteratively to obtain a target text recommendation model, wherein in each iteration process, the following operations are performed:
[0076] Inputting multiple recommended text samples in the training sample set and the true label of each recommended text sample into the text sorting model to be trained, and processing the feature vectors of the multiple recommended text samples by the text sorting model to be trained to obtain a predicted label corresponding to each recommended text sample; wherein the true label is used to characterize the semantic similarity between the recommended text sample and the corresponding search text;
[0077] Determining predicted cutoff positions of the plurality of recommended text samples according to the predicted label corresponding to each recommended text sample;
[0078] Determining a predicted truncation loss value of the predicted truncation position according to the true label;
[0079] According to the predicted truncation loss value, parameters of the text sorting model to be trained are adjusted.
[0080] According to a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a text sorting method when executing the computer program.
[0081] In the above-mentioned embodiment of the present application, the accuracy of the sorting result is improved by performing two sortings, namely, initial sorting and target sorting. Specifically, in response to a search request, a plurality of recommended texts related to at least one search term are screened out from the original text set, and the recommended texts are divided into different text domains by using the structural features of the text. Different weights are set for different text domains in consideration of the fit between the vocabulary in different text domains and the main content of the text. Therefore, when initially sorting each recommended text, the search text and each recommended text are determined according to the word frequency of at least one search term in each preset text domain of each recommended text and the weight corresponding to the preset document domain. By combining the semantic similarities between the words in the text, the correlation between the words can better reflect the correlation between the main content of the recommended text and the search term, so that when the recommended texts are initially sorted according to multiple semantic similarities, the sorting result can better meet the user's search intention; and after the recommended texts are initially sorted, according to the semantic information between the recommended texts, the trained target text sorting model is used to perform target sorting on the recommended texts after the initial sorting, which improves the sorting efficiency of the model. Moreover, since the semantic information between the recommended texts is used in the target sorting, the correlation between the recommended texts after the target sorting is stronger, and the sorting result is more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0082] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0083] Figure 1 A structural diagram of a semantic search system provided in an embodiment of the present application;
[0084] Figure 2 An overall framework diagram of the semantic search system provided in the embodiment of the present application;
[0085] Figure 3 A flow chart of an iterative training method for a target text sorting model provided in an embodiment of the present application;
[0086] Figure 4A A schematic diagram of the predicted truncation position provided in an embodiment of the present application;
[0087] Figure 4B A comparison diagram of the actual truncation position and the predicted truncation position provided in the embodiment of the present application;
[0088] Figure 5 A flowchart of a method for sorting text provided in an embodiment of the present application;
[0089] Figure 6 A structural diagram of a target text sorting model provided in an embodiment of the present application;
[0090] Fig. 7A A flow chart of a target sorting method provided in an embodiment of the present application;
[0091] Figure 7B A feature vector extraction flow chart provided for an embodiment of the present application;
[0092] Figure 7C A schematic diagram of the encoding method provided in an embodiment of the present application;
[0093] Figure 8 The result diagram after the initial sorting and target sorting provided in the embodiment of the present application;
[0094] Fig. 9 A structural diagram of a text sorting device provided in an embodiment of the present application;
[0095] Fig.10 A structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0096] In order to make the purpose, implementation mode and advantages of the present application clearer, the exemplary implementation mode of the present application will be clearly and completely described below in conjunction with the drawings in the exemplary embodiments of the present application. Obviously, the described exemplary embodiments are only part of the embodiments of the present application, rather than all the embodiments.
[0097] Based on the exemplary embodiments described in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the claims attached to this application. In addition, although the disclosure in this application is introduced according to one or several exemplary examples, it should be understood that each aspect of the disclosure can also constitute a complete implementation method separately.
[0098] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0099] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover but not exclude inclusion, for example, a product or device containing a series of components is not necessarily limited to those components clearly listed, but may include other components that are not clearly listed or inherent to these products or devices.
[0100] The term "module" as used in this application refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0101] In order to clearly describe the embodiments of the present application, the nouns in the present application are explained below.
[0102] Semantic search: It means that the search engine is no longer limited to the literal semantics of the request statement entered by the user, but sees the essence through the phenomenon, accurately captures the deep semantics behind the request statement entered by the user, and searches based on the captured deep semantics, thereby returning the search results that best meet the user's search intent.
[0103] Initial sorting: also referred to as rough sorting, refers to the weighted calculation of the semantic similarity scores of each text field of the recommended text corresponding to the search request based on a given search term, and then sorting them according to the scores.
[0104] Target sorting: also referred to as refined sorting, refers to calculating the semantic similarity between the recommended texts and the search terms based on the semantic information between the recommended texts after the initial sorting through a deep learning model, and performing a secondary sorting on the results after the initial sorting based on the semantic similarity.
[0105] Transformer model: It introduces the attention mechanism and abandons the inherent mode that the traditional encoder-decoder model must be combined with CNN or RNN. Compared with the seq2seq model, it reduces the amount of calculation, improves the efficiency of parallel operation, and improves the accuracy of the operation results.
[0106] BERT model: Bidirectional Encoder Representations from Transformer. The Bert model is the encoder network (Encoder) of the bidirectional Transformer. It introduces two pre-training tasks: Masked Language Model (MLE) and Next Sentence Predication (NSP). It uses large-scale unlabeled corpus training to obtain the semantic representation (Representation) of the text containing rich semantic information, and then fine-tunes the semantic representation of the text in a specific natural language processing (Natural Language Processing, NLP) task, and finally applies it to the specific NLP task.
[0107] Fine-tuning: In downstream tasks, it is usually necessary to train sample data corresponding to the specific downstream tasks to fine-tune the basic model parameters, and then apply the fine-tuned model to specific downstream tasks.
[0108] The design concept of this application is described below.
[0109] Sorting the results of semantic search is one of the core functional modules of aggregate retrieval. Through semantic search, users can query recommended texts that contain more semantically relevant words in addition to the search terms. Accurate sorting of recommended texts allows users to quickly find the texts they need.
[0110] At present, the method of sorting based on the correlation between words does not take into account the semantic information between the recommended texts, resulting in inaccurate sorting results. In addition, usually, different parts of the same text describe different emphases. Therefore, the degree of fit between the keywords in different parts and the main content of the text is also different. If the recommended text is considered as a whole, the contribution of the keywords in different parts to the main content cannot be reflected, so that the sorted results cannot meet the user's search intent.
[0111] In view of this, the embodiment of the present application provides a text sorting method and device, which uses word sense similarity to perform initial sorting on the recall results of the search request, and uses semantic similarity to perform secondary sorting on the results of the initial sorting, thereby improving the accuracy of the sorting results. Specifically, during the initial sorting, considering that the text gradually transitions from unstructured to structured, the recommended text is divided into multiple text domains according to the vertical structure, and different weights are set for each text domain. According to the weight of each text domain, the vocabulary and search terms in the corresponding text domain are weighted and calculated to obtain the word sense similarity between the search text and each recommended text. According to each word sense similarity, each recommended text is initially sorted. Compared with analyzing the recommended text as a whole, the word sense similarity can better reflect the relevance between the main content of the recommended text and the search, thereby improving the accuracy of the sorting results; and, according to the semantic information between the recommended texts, a deep learning model is used to perform secondary sorting on the recommended texts after the initial sorting, which improves the sorting efficiency of the deep learning model compared to directly using the deep learning model for sorting.
[0112] In order to more clearly understand the design ideas of the present application, the following is an example introduction to the application scenarios of the embodiments of the present application; see Figure 1 , a structural diagram of a semantic search ranking system is provided, the system includes an intelligent terminal 100 and a server 200, wherein the intelligent terminal 100 may include but is not limited to Figure 1 In the desktop computer 100-1 or smart phone 100-2, etc., a search program 110 may be installed on the smart terminal 100, which may include but is not limited to Figure 1 The search program 110-1 or the search program 110-2, etc., the server 200 is installed with a server-side application of the semantic search ranking system; the smart terminal 100 and the server 200 communicate with each other.
[0113] The target object opens the search program 110 on the smart terminal 100, enters the search text in the input box of the search program 110 and sends a search request. After receiving the search request, the server 200 obtains the search terms in the search text, and based on the search terms, selects multiple recommended texts from the original text collection of the database 300, sorts them and sends them to the smart terminal 100; the smart terminal 100 displays the sorted recommended texts to the target object.
[0114] The above-mentioned server 200 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers (such as but not limited to servers 200-1 to 200-3 shown in the figure), or multiple cloud servers in cloud service technology that provide 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, as well as big data and artificial intelligence platforms.
[0115] The above-mentioned intelligent terminal 100 can be a mobile terminal, a fixed terminal or a portable terminal, such as a mobile phone, a station, a unit, a device, a multimedia computer, a multimedia tablet, an Internet node, a communicator, a desktop computer, a laptop computer, a notebook computer, a netbook computer, a tablet computer, a personal communication system (PCS) device, a personal navigation device, a personal digital assistant (PDA), an audio / video player, a digital camera / camcorder, a positioning device, a television receiver, a radio broadcast receiver, an e-book device, a gaming device or any combination thereof, including accessories and peripherals of these devices or any combination thereof.
[0116] The above-mentioned database 300 can be a MySQL database, a Redis database, or a MongoDB database.
[0117] based on Figure 1 The overall framework diagram of the semantic search sorting provided by the embodiment of the present application is as follows Figure 2 As shown, each text in the original text set corresponds to an index. After receiving the search request, the search engine obtains the search term in the search text, and uses the inverted index method to filter out multiple recommended texts containing the search term from the original text set; a sorting algorithm (such as the BM25 algorithm) is used to calculate the semantic similarity between the search term and the keywords in each recommended text, and each recommended text is initially sorted based on the semantic similarity. The sorted results are input into a pre-trained target text sorting model, and each recommended text is sorted for a second time based on the semantic information between the recommended texts to obtain the final recommended text sorting result.
[0118] The training process of the target text sorting model involved in the embodiments of the present application is described in detail below.
[0119] First, obtain a training sample set for training the target text recommendation model. In the embodiment of the present application, the training sample set includes search logs for scenarios such as office areas, attendance processes and specifications, office assistants, and reimbursement processes. The number of search logs reaches more than 30,000, and the search logs include search text and user behavior, where user behavior includes click behavior, browsing time, jump targets, etc. After data processing and manual review, more than 20,000 pairs of standard search text samples and recommended text sample data sets are sorted out, and real labels are marked for recommended text samples based on the correlation between the search text samples and the recommended text samples. Among them, the real label is used to characterize the semantic similarity between the recommended text sample and the corresponding search text.
[0120] For example: if the recommended text sample 1 is related to the search text 1, the true label of the recommended text sample 1 is recorded as "1", and if the recommended text sample 2 is not related to the search text 1, the true label of the recommended text sample 2 is recorded as "0".
[0121] Furthermore, based on the acquired training sample set, the text sorting model to be trained is iterated multiple times to obtain a target text recommendation model.
[0122] With the continuous development of deep learning, deep learning models have been applied in the field of natural language processing. For example, the Transformer model based on the self-attention mechanism has stronger semantic feature extraction and long-distance feature capture capabilities compared to the traditional encoder-decoder model, and can be trained in parallel.
[0123] The BERT model was developed based on the Transformer model. There are two main ways to apply the BERT model in downstream tasks: Feature-based and Feature-based. The Feature-based method represents text as a vector, and the Feature-based method calculates text semantic similarity, vector recall, and other tasks based on the represented text vector.
[0124] The embodiment of the present application takes the BERT model as an example to train the target text sorting model. During iterative training, in order to better learn the model parameters, the embodiment of the present application considers the situation where the model output results are changed due to changes in sample labels, and at the same time, ensures that the parameter optimization process is simple and effective. Among them, the core problem of model training can be understood as: based on a given search text q, obtain the probability of the truncation position that can represent the output text distribution (such as a custom matrix).
[0125] During the model training process, when optimizing the model parameters, the embodiment of the present application uses the Maximum Likelihood Estimation (MLE) distribution with a penalty function instead of the Dirichlet distribution to improve the optimization target.
[0126] In the specific implementation, each iteration process refers to Figure 3 :
[0127] S301: multiple recommended text samples in the training sample set and the true label of each recommended text sample are input into the text sorting model to be trained, and the feature vectors of the multiple recommended text samples are processed by the text sorting model to be trained to obtain the predicted label corresponding to each recommended text sample.
[0128] In S301, the feature vector of the recommended text sample is extracted by the text sorting model to be trained, and the semantic similarity between the recommended text sample and the corresponding search text sample is calculated based on the extracted feature vector. If the semantic similarity is greater than the set threshold, it indicates that the recommended text sample is related to the search text sample, and the predicted label of the recommended text sample is marked as "1". Otherwise, it indicates that the recommended text sample is not related to the search text sample, and the predicted label of the recommended text sample is marked as "0".
[0129] S302: Determine predicted truncation positions of multiple recommended text samples according to the predicted label corresponding to each recommended text sample.
[0130] like Figure 4A As shown, assuming that the predicted label y of the recommended text sample 1 is "1", the predicted label y of the recommended text sample 2 is "1", the predicted label y of the recommended text sample 3 is "0", the predicted label y of the recommended text sample 4 is "1", and the predicted label y of the recommended text sample 5 is "1", the prediction is truncated at the recommended text sample 3, and the truncation position is recorded as break.
[0131] S303: Determine the truncation loss value corresponding to the predicted truncation position according to the true label.
[0132] like Figure 4B As shown, according to the true label of each recommended text sample, it should be truncated at recommended text sample 4, but it is actually predicted to be truncated at recommended text sample 3. Therefore, the truncation loss value of the predicted truncation position can be determined based on the true truncation position determined by the true label.
[0133] In specific implementation, based on the penalty function s, the penalty score is regularized and the probability distribution function of the predicted truncation position is obtained:
[0134]
[0135] Among them, p break represents the penalty probability of each recommended text sample being truncated at the predicted truncation position break, B is the total number of predicted truncation positions, y represents the predicted label of each recommended text sample, s break (y) represents the penalty score of each recommended text sample being truncated at the predicted truncation position break, and τ is a hyperparameter that controls the range of y values.
[0136] Furthermore, the MLE method is used to learn the predicted truncation loss value of the predicted truncation position with the actual truncation position corresponding to the real sample label as a reference. The loss value uses the log-likelihood, and the calculation formula is as follows:
[0137] l mle =-∑ break δ break′ *logp break (D; θ) Formula 2
[0138] Where D represents the set of recommended text samples, θ represents the parameters of the text ranking model, and δ break′ represents the Dirichlet distribution of the true truncation position break′ corresponding to the true label of each recommended text sample. At the true truncation position break′, δ break =1, other positions break =0.
[0139] As can be seen from Formula 2, the MLE method treats each recommended text sample (including the recommended text samples that do not match the search text sample) equally, which ignores the actual distribution state of each recommended text sample at the actual truncation position break′, causing inconsistency between the training process and the testing process of the model.
[0140] In order to solve the above text, the embodiment of the present application determines the real part state of each recommended text sample according to the real truncation position determined by the real label of each recommended text sample, and the calculation formula is as follows:
[0141]
[0142] Among them, q break′ represents the penalty probability of each recommended text sample being truncated at the real truncation position break′, B is the total number of real truncation positions, y * represents the true label of each recommended text sample, s break′ (y * ) represents the penalty score of each recommended text sample being truncated at the actual truncation position break′, τ is the control y * Hyperparameters of the range metric.
[0143] Get q break′Then, use q in formula 3 break′ Replace δ in Formula 2 break′ , thus solving the problem of inconsistency between model training and testing.
[0144] By updating the loss value calculation formula of Formula 2, the distribution of each recommended text sample output by the model is made close to the normal distribution with a penalty term, thereby improving the optimization result of the model.
[0145] S304: Adjust parameters of the text sorting model to be trained according to the predicted truncation loss value.
[0146] In S304, mle The parameter θ of the text sorting model is adjusted until the maximum number of iterations is reached or the preset convergence condition is met, then the adjustment is stopped to obtain a trained target text sorting model.
[0147] After obtaining the trained target text sorting model, the embodiment of the present application tests the target text sorting model through a test sample set, and the evaluation index of the test result is marked as F1@break, and the formula is as follows:
[0148]
[0149]
[0150]
[0151] Among them, N D represents the number of test recommendation texts in the test sample set, y * represents the true label of the test recommendation text, break represents the cutoff position of the test recommendation text in the test sample set, B is the total number of cutoff positions in the test sample set, and δ represents the Dirichlet function.
[0152] In order to verify the superiority of the target text sorting model, the present application embodiment takes the search log files of scenes such as office field, attendance process and specification, office assistant and reimbursement process as examples, and tests the sorting results of the target text sorting model. The specific test results are as follows:
[0153] Table 1. Ranking results of each algorithm model
[0154]
[0155]
[0156] It can be seen from Table 1 that the BM25 algorithm and target text ranking model provided in the embodiment of the present application are superior to the BM25 algorithm that comes with the search engine. The BM25 algorithm of the present application is introduced in detail below.
[0157] During the testing process of the embodiment of the present application, it was found that in the results sorted by the target text sorting model, the top-ranked test recommendation texts were not limited to texts including the search terms, but also included texts related to the search terms.
[0158] For example, in the search results for the search term "business trip", the top-ranked text also includes the "reimbursement" text which is semantically related to the "business trip"; in the search results for the search term "attendance", the top-ranked text also includes the "punch in" text and "make-up sign-in" text which are semantically related to the "attendance"; in the search results for the search term "annual leave", the top-ranked text also includes the "work time" text which is semantically related to the "annual leave".
[0159] In an embodiment of the present application, after obtaining a trained target text sorting model, the target text sorting model is applied to implement the text sorting method provided in an embodiment of the present application.
[0160] Please refer to Figure 5 , represents the text sorting method designed in the embodiment of the present application, which is applied to the semantic search sorting system. The program is executed by the server of the search engine, as follows:
[0161] S501: In response to a search request sent by a target object, a plurality of recommended texts are screened out from an original text set according to at least one search term in a search text carried in the search request.
[0162] In S501, after receiving the search request sent by the target object, the server obtains the search text carried in the search request, segments the search text, extracts at least one search word from the search text, and uses an inverted text index to filter out multiple recommended texts containing at least one search word from the original text collection based on the extracted at least one search word.
[0163] S502: Determine the semantic similarity between the search text and each recommended text according to the frequency of at least one search word in each preset text field of each recommended text and the weight corresponding to the preset text field.
[0164] There are many algorithms for sorting based on the correlation between words, representative examples include the Term Frequency-Inverse Document Frequency (TF-IDF) algorithm, the BM25 algorithm, etc. The embodiment of the present application is based on the BM25 algorithm, and makes certain improvements to BM25, dividing the recommended text into multiple preset text domains, while considering that different preset text domains contribute differently to the sorting, learning the weights of each preset text domain through the algorithm, and performing initial sorting on each recommended text based on the divided preset text domains and the corresponding weights.
[0165] In specific implementation, in S502, after obtaining a plurality of recommended texts, each recommended text is divided into a plurality of preset text domains, wherein the preset text domains include but are not limited to a subject domain, a keyword domain, and a document domain.
[0166] For the topic domain, a trained topic model, such as a Latent Dirichlet Allocation (LDA) model, is used to label each recommended text with a topic label to obtain the topic domain of each recommended text.
[0167] For example, for the first recommended text in the office field, the extracted subject tags include loan, deposit, and interest, so the subject domain of the first recommended text is {loan, deposit, interest}.
[0168] For the keyword domain, each recommended text is segmented according to the pre-generated keyword word library, and the keyword domain of each recommended text is generated according to the keywords in each recommended text and the information entropy of the corresponding recommended text. Among them, the information entropy can reflect the relevance between the keywords and the main content of the corresponding recommended text.
[0169] Taking the first recommended sample as an example, the extracted keywords are loan, mortgage, and car loan. The information entropy between loan and the first recommended text is 0.5, the information entropy between mortgage and the first recommended text is 0.8, and the information entropy between car loan and the first recommended text is 0.2. The keyword domain of the first recommended text is {loan, mortgage}.
[0170] Optionally, the keywords in the keyword thesaurus may be extracted from the collected training sample set using a keyword extraction algorithm to improve the accuracy of word segmentation.
[0171] For the statistical domain, a statistical domain of each recommended text is generated according to the text length of each recommended text.
[0172] For example, the length of the first recommended text is 100 bytes, the first 28 bytes describe the background information of the current loan, the middle 67 bytes describe the calculation method of the mortgage, and the last 5 bytes summarize the mortgage form. Usually people pay less attention to the background information and summary, so it can be determined that the statistical domain of the first recommended text is the middle 67 bytes.
[0173] After each recommended text is divided into multiple preset text domains, the term frequency-inverse document frequency (TF-IDF) algorithm is used to count the frequency of at least one search term in each preset text domain, and the semantic similarity between the search text and each recommended text is determined by combining the pre-learned weight of each preset text domain. The formula for calculating semantic similarity of the improved BM25 algorithm is:
[0174]
[0175]
[0176]
[0177] Among them, q i represents the i-th search term in the search text, d i represents a recommended text related to the i-th search term, 0.5 is the training coefficient, N is the total number of recommended texts, O is the total number of recommended texts related to each search term, and n i is the total number of recommended texts corresponding to the i-th search term, r i is the number of recommended texts related to the i-th search term, k1 is the adjustment factor, u is the number of preset document domains in a recommended text, and w k is the weight corresponding to the kth preset document domain, f ui is the frequency of the ith search term in the preset document domain, f i u is the total frequency of the ith search term in the preset document domain, B u The length of the preset document domain, ul u The actual length of each preset document field, uvul u is the average length of each preset document domain, b u Length adjustment factor for each preset document field.
[0178] S503: performing an initial sorting of the recommended texts according to the multiple word meaning similarities.
[0179] In S503, based on the semantic similarity between the search words in the search text calculated by Formula 7 and the vocabulary in each recommended text, the recommended texts are initially sorted, wherein the higher the semantic similarity corresponding to the corresponding recommendation, the higher the ranking position.
[0180] The results of the initial sorting of the search text entered for the target object are shown in Table 2.
[0181] Table 2. Results after initial sorting of search text
[0182] Text Index Word Semantic Similarity Initial sorting results 3 0.72 Recommended text 3 1 0.713 Recommended text 1 4 0.7 Recommended text 4 2 0.697 Recommended text 2 5 0.68 Recommended text 5 … … …
[0183] S504: According to the semantic information between the recommended texts, the trained target text sorting model is used to perform target sorting on the recommended texts after the initial sorting.
[0184] In the embodiment of the present application, the structure of the target text sorting model is as follows: Figure 6As shown, it mainly includes an encoding layer, an attention layer, and a decision layer. Among them, the encoding layer uses a two-layer bidirectional long short-term memory network (Long Short-Term Memory, LSTM) as an encoder to extract the hidden semantic information between the front and back recommended texts, and encode each recommended text in combination with the feature vectors of the recommended texts. The attention layer is intended to capture the long-distance dependencies between the recommended texts. In particular, in each recommended text after the initial sorting, the multi-head attention mechanism allows the text to be directly associated with any other text. After each recommended text is associated with other recommended texts, the attention coefficient between each recommended text and other recommended texts is calculated, and the feature vector of the recommended text itself is adjusted according to the attention coefficient. For each search text q, in the corresponding multiple recommended texts, the decision layer needs to calculate the appropriate truncation position. In order to obtain the probability of each recommended text at each truncation position, the embodiment of the present application adopts a multilayer perceptron (Multilayer Perceptron, MLP) network and a softmax function in the decision layer.
[0185] Based on the above target text ranking model, each recommended text is ranked by target, see Fig. 7A :
[0186] S701: encoding each recommended text after the initial sorting according to the feature vector of each recommended text after the initial sorting and the bidirectional semantic information between each recommended text after the initial sorting to obtain the encoding vector of each recommended text after the initial sorting.
[0187] For a recommended text j among the recommended texts after the initial sorting, the feature vector extraction process is shown in Figure 7B :
[0188] S7011: Use the semantic similarity between the search text and a recommended text as the first feature vector of a recommended text.
[0189] When the BM25 algorithm is used for initial sorting, the semantic similarity between the search text and a recommended text has been obtained. In S7011, the semantic similarity is used as the first feature vector of a recommended text, denoted by E j .
[0190] S7012: Calculate the semantic similarity between a recommended text and an adjacent recommended text.
[0191] In S7012, the doc2vec model is used to extract basic features of a recommended text and its adjacent recommended texts, including text length, number of non-repeating words, etc., and the extracted basic features are represented by vectors. After obtaining the basic feature vectors of a recommended text and its adjacent recommended texts, the cosine value of a recommended text and its adjacent recommended texts is calculated to obtain the semantic similarity.
[0192] S7013: Generate a second feature vector of a recommended text based on the basic features of the recommended text and the corresponding semantic similarity, denoted as F j .
[0193] In S7013, the basic features and the semantic similarity are used as a second feature vector of a recommended text.
[0194] S7014: Concatenate the first feature vector and the second feature vector to obtain a feature vector of the recommended text.
[0195] In S7014, the feature vector of a recommended text is denoted by x j =[E j |F j ].
[0196] based on Figure 7B After obtaining the feature vector of each recommended text, it is input into the encoding layer of the target text sorting model. The encoding layer is combined to extract the hidden bidirectional semantic information between the recommended texts for encoding, and the encoding vector h of each recommended text after the initial sorting is obtained. j .
[0197] S702: Using a multi-head attention mechanism, the encoding vectors of each recommended text after the initial sorting are adjusted and regularized.
[0198] Assuming that the total number of recommended texts after the initial sorting is N, for a recommended text j among the recommended texts after the initial sorting, the adjustment process of the encoding vector is as follows: Figure 7C :
[0199] S7021: Calculate the semantic similarity between a recommended text and N-1 recommended texts respectively.
[0200] In S7021, based on the encoding vectors of the recommended texts, the cosine values of one recommended text and the other N-1 recommended texts are calculated to obtain the semantic similarity between one recommended text and the other N-1 recommended texts.
[0201] S7022: Determine an attention coefficient corresponding to a recommended text according to N-1 semantic similarities corresponding to a recommended text.
[0202] In S7022, based on the multi-head attention mechanism, the attention coefficient corresponding to a recommended text is calculated according to the N-1 semantic similarities corresponding to the recommended text. The calculation formula is as follows:
[0203]
[0204] in, H represents the number of heads in the model, Q j , K j 、V j ∈R t×(t / n) Represent the query matrix, key matrix, and value matrix of the jth attention head, respectively. They represent the query matrix weight, key matrix weight, and value matrix weight of the j-th attention head respectively, R represents a set of real numbers, and t represents the dimension.
[0205] Formula 10 uses the dimension scaling factor This can prevent the problem of excessive increase in value when calculating the attention coefficient in dot multiplication.
[0206] S7023: Adjust an encoding vector of a recommended text according to the attention coefficient, and perform regularization representation on the adjusted encoding vector.
[0207] In S7023, after obtaining the attention coefficient of a recommended text, the encoding vector of the recommended text is adjusted according to the attention coefficient, and the adjustment formula is:
[0208] M j =concatenation(head j )W H Formula 11
[0209] Among them, M j is the adjusted encoding vector of the jth recommended text, W H ∈R t×t ,R represents the set of real numbers, and t represents the dimension.
[0210] After adjustment, a refined vector representation of the recommended text is obtained, and the adjusted encoding vector is regularized.
[0211] In the embodiment of the present application, the regularized expression formula of each recommended text is:
[0212] M'=layerNorm(M+H) Formula 12
[0213] M=multiHeadAttention(H)=concatenation(head1,…,head j )W H
[0214] Formula 13
[0215] S703: Determine a truncation position set of each recommended text after initial sorting according to the encoding vector of each recommended text after regularization representation, and determine the probability of each truncation position in the truncation position set.
[0216] In S703, the MLP network and the softmax function are used in the decision layer to determine the probability of each truncation position according to the encoding vector after regularization representation. The calculation formula is as follows:
[0217] p = softmax(MLP(M′)) Formula 14
[0218] in, B represents the total number of truncation positions in the truncation position set, and p represents the probability of B truncation positions.
[0219] S704: performing target sorting on each recommended text after the initial sorting according to the probability of each truncation position.
[0220] like Figure 8 As shown, there are two truncation positions in the truncation position set, which are denoted as break1 and break2. The two truncated recommended texts have weaker semantic relevance, that is, the semantic similarity between recommended text 1 and recommended text 2 and recommended text 3 is low, and the semantic similarity between recommended text 2 and recommended text 4 and recommended text 5 is low. Therefore, recommended text 1 and recommended text 2 are moved downward, and recommended text 4 and recommended text 5 are moved upward. Finally, the sequence of recommended texts displayed to the target object is recommended text 3->recommended text 4->recommended text 5->recommended text 1->recommended text 2->….
[0221] In the embodiments of the present application, the BM25 algorithm is improved by dividing the recommended text into multiple preset text domains, and a weight is set for each preset text domain, thereby highlighting the different contributions of the vocabulary in different preset text domains to the sorting, so that when the initial sorting is performed based on the similarity between words calculated in the preset text domain, the sorting result is more accurate; through the initial sorting of the BM25 algorithm, multiple recommended texts are recalled for the target text sorting model, which solves the problem of low operating efficiency of deep learning algorithms on large data sets, and can meet the millisecond-level response of online searches even when the amount of text data is hundreds of millions; and in the target text sorting model, a multi-head attention mechanism is used to dynamically encode variable-length sequences through attention and masking, and at the same time, the semantic vector is divided into multiple spaces through multiple heads, which solves the problems of long-distance dependency, no position deviation, and parallel calculation, which not only solves the semantic representation ability, but also speeds up the calculation speed of the model and improves the sorting efficiency.
[0222] At the same time, the embodiment of the present application adopts the idea of double sorting, namely initial sorting and target sorting, which not only improves the accuracy of the sorting results, but also solves the problem that it is difficult to match documents that meet the user's search intent based on the semantic similarity between words.
[0223] For example, when searching for text related to "new infrastructure", the sorted text includes recommended texts such as "blockchain" and "5G" related to "new infrastructure". If the search engine's built-in sorting algorithm is used, the sorted text does not include recommended texts such as "blockchain" and "5G".
[0224] Based on the same inventive concept, the present application embodiment provides a text sorting device, see Fig. 9 ,include:
[0225] A response module 901 is used to respond to a search request sent by a target object and filter out a plurality of recommended texts from an original text set according to at least one search word in a search text carried in the search request;
[0226] A similarity calculation module 902, configured to determine the semantic similarity between the search text and each recommended text according to the frequency of at least one search word in each preset text field of each recommended text and the weight corresponding to the preset text field;
[0227] A first sorting module 903, used to perform initial sorting on each recommended text according to multiple word meaning similarities;
[0228] The second sorting module 904 is used to perform target sorting on the recommended texts after the initial sorting by using the trained target text sorting model according to the semantic information between the recommended texts.
[0229] Optionally, the method further includes a text domain division module 905, which is used to:
[0230] Using the trained topic model, label each recommended text with a topic label to obtain the topic domain of each recommended text; and
[0231] According to the pre-generated keyword word library, each recommended text is segmented, and the keyword domain of each recommended text is generated according to the keywords in each recommended text and the information entropy of the corresponding recommended text; and
[0232] According to the text length of each recommended text, a statistical domain of each recommended text is generated.
[0233] Optionally, the formula for calculating the semantic similarity between the search text and a recommended text is as follows:
[0234]
[0235]
[0236]
[0237] Among them, q i represents the i-th search term in the search text, d i represents a recommended text related to the i-th search term, 0.5 is the training coefficient, N is the total number of recommended texts, O is the total number of recommended texts related to each search term, and n i is the total number of recommended texts corresponding to the i-th search term, r i is the number of recommended texts related to the i-th search term, k1 is the adjustment factor, u is the number of preset document domains in a recommended text, and w k is the weight corresponding to the kth preset document domain, f ui is the frequency of the ith search term in the preset document domain, f i u is the total frequency of the ith search term in the preset document domain, B u The length of the preset document domain, ul u The actual length of each preset document field, uvul u is the average length of each preset document domain, b u Length adjustment factor for each preset document field.
[0238] Optionally, the second sorting module 904 is specifically configured to:
[0239] According to the feature vectors of the recommended texts after the initial sorting and the bidirectional semantic information between the recommended texts after the initial sorting, the recommended texts after the initial sorting are respectively encoded to obtain the encoding vectors of the recommended texts after the initial sorting;
[0240] A multi-head attention mechanism is used to adjust the encoding vectors of each recommended text after the initial sorting and perform regularization representation;
[0241] Determine a set of truncation positions of each recommended text after initial sorting according to the encoding vector of each recommended text after regularization, and determine the probability of each truncation position in the set of truncation positions;
[0242] According to the probability of each truncation position, each recommended text after the initial sorting is targeted and sorted.
[0243] Optionally, the second sorting module 904 is specifically configured to:
[0244] For one of the recommended texts after the initial sorting:
[0245] The semantic similarity between the search text and a recommended text is used as the first feature vector of a recommended text;
[0246] Calculate the semantic similarity between a recommended text and adjacent recommended texts;
[0247] Generate a second feature vector of the recommended text according to the basic features of the recommended text and the corresponding semantic similarity;
[0248] The first feature vector and the second feature vector are concatenated to obtain a feature vector of the recommended text.
[0249] Optionally, the second sorting module 904 is specifically configured to:
[0250] For one of the recommended texts after the initial sorting:
[0251] Calculate the semantic similarity between a recommended text and N-1 recommended texts, where N is the total number of recommended texts;
[0252] According to the N-1 semantic similarities corresponding to a recommended text, an attention coefficient corresponding to a recommended text is determined;
[0253] According to the attention coefficient, an encoding vector of a recommended text is adjusted, and the adjusted encoding vector is regularized.
[0254] Optionally, a training module 906 is also included, which is used to:
[0255] Get a training sample set;
[0256] Based on the training sample set, the text sorting model to be trained is trained multiple times to obtain the target text recommendation model, wherein in each iteration, the following operations are performed:
[0257] Inputting multiple recommended text samples in the training sample set and the true label of each recommended text sample into the text sorting model to be trained, processing the feature vectors of the multiple recommended text samples through the text sorting model to be trained, and obtaining the predicted label corresponding to each recommended text sample; wherein the true label is used to characterize the semantic similarity between the recommended text sample and the corresponding search text;
[0258] Determine predicted cutoff positions of multiple recommended text samples according to the predicted label corresponding to each recommended text sample;
[0259] According to the true label, determine the predicted truncation loss value of the predicted truncation position;
[0260] According to the predicted truncation loss value, the parameters of the text sorting model to be trained are adjusted.
[0261] As an example, Fig. 9The device in can be used in the text sorting method provided in the embodiment of the present application and can achieve the same technical effect, which will not be repeated here.
[0262] The above device is an example of a hardware entity. Fig.10 The electronic device shown includes a processor 1001 , a memory 1002 and at least one external communication interface 1003 ; the processor 1001 , the memory 1002 and the external communication interface 1003 are all connected via a bus 1004 .
[0263] The memory 1002 stores a computer program;
[0264] When the processor 1001 executes the computer program, a text sorting method discussed above is implemented.
[0265] Fig.10 In the figure, one processor 1001 is taken as an example, but the number of processors 1001 is not limited in practice.
[0266] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0267] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0268] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0269] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0270] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A text sorting method, characterized in that: The method comprises: In response to a search request sent by a target object, a plurality of recommended texts are screened out from an original text set according to at least one search term in a search text carried in the search request; According to the frequency of the at least one search word in each preset text field of each recommended text and the weight corresponding to the preset text field, the semantic similarity between the search text and each recommended text is determined; wherein the calculation formula of the semantic similarity between the search text and a recommended text is as follows: q i represents the i-th search term in the search text, d i represents a recommended text related to the i-th search term, 0.5 is the training coefficient, N is the total number of recommended texts, O is the total number of recommended texts related to each search term, and n i is the total number of recommended texts corresponding to the i-th search term, r i is the number of recommended texts related to the i-th search term, k1 is the adjustment factor, u is the number of preset document domains in a recommended text, and w k is the weight corresponding to the kth preset document domain, f ui is the frequency of the ith search term in the preset document domain, is the total frequency of the ith search term in the preset document domain, B u The length of the preset document domain, ul u The actual length of each preset document field, uvul u is the average length of each preset document domain, b u Length adjustment factor for each preset document field; Perform initial sorting of each recommended text based on multiple word meaning similarities; According to the semantic information between the recommended texts, the trained target text sorting model is used to perform target sorting on the recommended texts after the initial sorting.
2. The method according to claim 1, characterized in that Each of the preset text fields at least includes a subject field, a keyword field, and a statistics field. Each of the preset text fields is determined in the following manner: Using the trained topic model, label each recommended text with a topic label to obtain the topic domain of each recommended text; and According to the pre-generated keyword word library, each recommended text is segmented, and the keyword domain of each recommended text is generated according to the keywords in each recommended text and the information entropy of the corresponding recommended text; as well as According to the text length of each recommended text, a statistical domain of each recommended text is generated.
3. The method according to claim 1, characterized in that The method uses a trained target sorting model to perform target sorting on the recommended texts after the initial sorting according to the semantic information between the recommended texts, including: According to the feature vectors of the recommended texts after the initial sorting and the bidirectional semantic information between the recommended texts after the initial sorting, the recommended texts after the initial sorting are respectively encoded to obtain the encoding vectors of the recommended texts after the initial sorting; A multi-head attention mechanism is used to adjust the encoding vectors of each recommended text after the initial sorting and perform regularization representation; Determining a set of truncation positions of each recommended text after initial sorting according to the encoding vector of each recommended text after regularization representation, and determining the probability of each truncation position in the set of truncation positions; According to the probability of each truncation position, each recommended text after the initial sorting is targeted and sorted.
4. The method according to claim 3, characterized in that The feature vectors of each recommended text after initial sorting are determined in the following way: For one of the recommended texts after the initial sorting: Using the semantic similarity between the search text and the one recommended text as a first feature vector of the one recommended text; Calculating the semantic similarity between the one recommended text and an adjacent recommended text; generating a second feature vector of the recommended text according to the basic features of the recommended text and the corresponding semantic similarity; The first feature vector and the second feature vector are concatenated to obtain a feature vector of the recommended text.
5. The method according to claim 3, characterized in that The multi-head attention mechanism is used to adjust the encoding vectors of each recommended text after the initial sorting, including: For one of the recommended texts after the initial sorting: Calculating the semantic similarity between the one recommended text and N-1 recommended texts respectively, where N is the total number of the multiple recommended texts; Determining an attention coefficient corresponding to the recommended text according to N-1 semantic similarities corresponding to the recommended text; According to the attention coefficient, the encoding vector of the recommended text is adjusted, and the adjusted encoding vector is regularized.
6. The method according to any one of claims 1 to 5, characterized in that The target text sorting model is trained in the following way: Get a training sample set; Based on the training sample set, the text sorting model to be trained is trained multiple times iteratively to obtain a target text recommendation model, wherein in each iteration process, the following operations are performed: Inputting multiple recommended text samples in the training sample set and the true label of each recommended text sample into the text sorting model to be trained, and processing the feature vectors of the multiple recommended text samples by the text sorting model to be trained to obtain a predicted label corresponding to each recommended text sample; wherein the true label is used to characterize the semantic similarity between the recommended text sample and the corresponding search text; Determining predicted cutoff positions of the plurality of recommended text samples according to the predicted label corresponding to each recommended text sample; Determining a predicted truncation loss value of the predicted truncation position according to the true label; According to the predicted truncation loss value, parameters of the text sorting model to be trained are adjusted.
7. A text sorting device, characterized in that: include: A response module, configured to respond to a search request sent by a target object and filter out a plurality of recommended texts from an original text set according to at least one search term in a search text carried in the search request; A similarity calculation module is used to determine the semantic similarity between the search text and each recommended text according to the frequency of the at least one search word in each preset text field of each recommended text and the weight corresponding to the preset text field; wherein the calculation formula of the semantic similarity between the search text and a recommended text is as follows: q i represents the i-th search term in the search text, d i represents a recommended text related to the i-th search term, 0.5 is the training coefficient, N is the total number of recommended texts, O is the total number of recommended texts related to each search term, and n i is the total number of recommended texts corresponding to the i-th search term, r i is the number of recommended texts related to the i-th search term, k1 is the adjustment factor, u is the number of preset document domains in a recommended text, and w k is the weight corresponding to the kth preset document domain, f ui is the frequency of the ith search term in the preset document domain, is the total frequency of the ith search term in the preset document domain, B u The length of the preset document domain, ul u The actual length of each preset document field, uvul u is the average length of each preset document domain, b u Length adjustment factor for each preset document field A first sorting module, used for initially sorting each recommended text according to multiple word meaning similarities; The second sorting module is used to perform target sorting on the recommended texts after the initial sorting according to the semantic information between the recommended texts using the trained target text sorting model.
8. The device according to claim 7, characterized in that It also includes a text domain segmentation module for: Using the trained topic model, label each recommended text with a topic label to obtain the topic domain of each recommended text; and According to the pre-generated keyword word library, each recommended text is segmented, and the keyword domain of each recommended text is generated according to the keywords in each recommended text and the information entropy of the corresponding recommended text; as well as According to the text length of each recommended text, a statistical domain of each recommended text is generated.
9. The device according to claim 7, characterized in that The second sorting module is specifically used for: According to the feature vectors of the recommended texts after the initial sorting and the bidirectional semantic information between the recommended texts after the initial sorting, the recommended texts after the initial sorting are respectively encoded to obtain the encoding vectors of the recommended texts after the initial sorting; A multi-head attention mechanism is used to adjust the encoding vectors of each recommended text after the initial sorting and perform regularization representation; Determining a set of truncation positions of each recommended text after initial sorting according to the encoding vector of each recommended text after regularization representation, and determining the probability of each truncation position in the set of truncation positions; According to the probability of each truncation position, each recommended text after the initial sorting is targeted and sorted.
10. The device according to claim 9, characterized in that The second sorting module is specifically used for: For one of the recommended texts after the initial sorting: Using the semantic similarity between the search text and the one recommended text as a first feature vector of the one recommended text; Calculating the semantic similarity between the one recommended text and an adjacent recommended text; generating a second feature vector of the recommended text according to the basic features of the recommended text and the corresponding semantic similarity; The first feature vector and the second feature vector are concatenated to obtain a feature vector of the recommended text.
11. The device according to claim 9, characterized in that The second sorting module is specifically used for: For one of the recommended texts after the initial sorting: Calculating the semantic similarity between the one recommended text and N-1 recommended texts respectively, where N is the total number of the multiple recommended texts; Determining an attention coefficient corresponding to the recommended text according to N-1 semantic similarities corresponding to the recommended text; According to the attention coefficient, the encoding vector of the recommended text is adjusted, and the adjusted encoding vector is regularized.
12. The device according to any one of claims 7 to 11, characterized in that Also includes training modules for: Get a training sample set; Based on the training sample set, the text sorting model to be trained is trained multiple times iteratively to obtain a target text recommendation model, wherein in each iteration process, the following operations are performed: Inputting multiple recommended text samples in the training sample set and the true label of each recommended text sample into the text sorting model to be trained, and processing the feature vectors of the multiple recommended text samples by the text sorting model to be trained to obtain a predicted label corresponding to each recommended text sample; wherein the true label is used to characterize the semantic similarity between the recommended text sample and the corresponding search text; Determining predicted cutoff positions of the plurality of recommended text samples according to the predicted label corresponding to each recommended text sample; Determining a predicted truncation loss value of the predicted truncation position according to the true label; According to the predicted truncation loss value, parameters of the text sorting model to be trained are adjusted.
13. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program.
