Text retrieval method and device, storage medium and electronic equipment
Through the pre-trained text retrieval model and text rearrangement model, combined with the popularity and timeliness characteristics of the knowledge base, the problem of insufficient matching and timeliness of text retrieval in the existing technology is solved, and a more efficient text retrieval effect is achieved.
Patent Information
- Application Number
- CN202311271819.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-27
- Publication Date
- 2024-10-22
AI Technical Summary
Existing text retrieval technology cannot meet the matching, professionalism and timeliness requirements of text retrieval, and lacks consideration of user personalization and popularity characteristics.
Sentence vectors are generated through the pre-trained text retrieval model, the popularity and timeliness features in the knowledge base are obtained, the retrieval results are adjusted based on similarity and distance, and the text rearrangement model is used for reordering, taking into account user preferences and text features.
It improves the matching, professionalism and timeliness of text retrieval, meets the personalized needs of users, dynamically adjusts retrieval results, and improves the accuracy and relevance of retrieval.
Smart Images

Figure CN118820451A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data retrieval, and in particular to a text retrieval method, a text retrieval device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Text retrieval is a classic problem in natural language processing, which mainly studies the semantic similarity of two texts. Existing technologies mainly obtain a segmented text set through word segmentation and determine the cosine similarity of each segmentation vector to achieve text retrieval, which cannot meet the requirements of text retrieval such as matching, professionalism, and timeliness. Summary of the invention
[0003] The purpose of the present disclosure is to provide a text retrieval method, a text retrieval device, an electronic device and a computer-readable storage medium, thereby solving the problem that the related art cannot meet the requirements of matching degree, professionalism, timeliness, etc. of text retrieval to a certain extent.
[0004] According to a first aspect of the present disclosure, a text retrieval method is provided, comprising: generating a sentence vector of a retrieval text through a pre-trained text retrieval model, wherein the sentence vector is used to characterize the semantic features of the retrieval text; obtaining the popularity features and timeliness features of each text in a knowledge base, and searching the knowledge base for a first retrieval result corresponding to the sentence vector based on the popularity features and the timeliness features to obtain a first retrieval result set; initializing a second retrieval result set, and determining the second retrieval result set based on the similarity of each first retrieval result in the first retrieval result set and the distance to the second retrieval result set; for each second retrieval result in the second retrieval result set, concatenating each second retrieval result with the retrieval text, and determining a matrix corresponding to the concatenated text, wherein the matrix includes text information and position information of the concatenated text; inputting the matrix, the popularity features and the timeliness features of the second retrieval result into a pre-trained text rearrangement model to obtain positive scores and negative scores of each second retrieval result, and reordering the second retrieval results according to the positive scores and the negative scores.
[0005] In an exemplary embodiment of the present disclosure, the acquisition of the popularity feature and timeliness feature of each text in the knowledge base includes: for a text newly entered into the knowledge base, recording the entry time of the text, and setting the initial value of the number of visits to the text to 0; when it is detected that the text is accessed, updating the value of the number of visits; when the text is retrieved, determining the popularity feature of the text based on the number of visits, and determining the timeliness feature of the text based on the entry time and the current retrieval time.
[0006] In an exemplary embodiment of the present disclosure, the first search result corresponding to the sentence vector is retrieved in the knowledge base based on the popularity feature and the timeliness feature to obtain a first search result set, including: determining the term frequency-inverse document frequency of each of the first search results; calculating the weighted sum of the popularity feature, the timeliness feature and the term frequency-inverse document frequency of each of the first search results according to preset weights, and determining the first search result set based on the weighted sum.
[0007] In an exemplary embodiment of the present disclosure, the second search result set is determined based on the similarity of each first search result in the first search result set and the distance to the second search result set, including: calculating the cosine similarity between each first search result and the search text as the similarity of the first search result; moving the first search result with the largest similarity to the second search result set; traversing the first search result set and calculating the distance from the remaining first search results in the first search result set to the second search result set; for each first search result, calculating the weighted sum of the similarity and the distance according to a preset weight, and moving the first search result with the largest weighted sum to the second search result set; repeating the steps of traversing the first search result set to the step of moving the first search result with the largest weighted sum to the second search result set until the first search result set is empty.
[0008] In an exemplary embodiment of the present disclosure, determining the matrix corresponding to the concatenated text includes: inputting the concatenated text into the text retrieval model, encoding to obtain a sentence vector of the concatenated text; using the sorting number of the second retrieval result in the second retrieval result set as the position information; encoding the sentence vector and the sorting number to obtain the matrix corresponding to the concatenated text.
[0009] In an exemplary embodiment of the present disclosure, the reordering of the second search results based on the positive score and the negative score includes: arranging the second search results in descending order based on the positive score; and for the second search results with the same positive score, arranging them in ascending order based on the negative score.
[0010] In an exemplary embodiment of the present disclosure, the training method of the text rearrangement model includes: obtaining historical search text, and determining the matrix of the historical search text, the heat feature and the timeliness feature of the second search result; obtaining the number of likes and dislikes of the second search result by users, and logarithmically obtaining the positive score and the negative score of the second search result as training labels; training the network parameters of the pre-trained model based on the matrix, the heat feature and the timeliness feature; and correcting the network parameters based on the training labels to obtain the text rearrangement model.
[0011] In an exemplary embodiment of the present disclosure, before generating a sentence vector of the retrieval text through a pre-trained text retrieval model, the method further includes: obtaining vocabulary in a field corresponding to the current application scenario; adding the vocabulary to the knowledge base, and normalizing the vocabulary.
[0012] According to a second aspect of the present disclosure, a text retrieval device is provided, comprising: a vector generation module, used to generate a sentence vector of a retrieval text through a pre-trained text retrieval model, wherein the sentence vector is used to represent the semantic features of the retrieval text; a first retrieval result set determination module, used to obtain the popularity feature and the timeliness feature of each text in a knowledge base, and retrieve the first retrieval result corresponding to the sentence vector in the knowledge base based on the popularity feature and the timeliness feature to obtain a first retrieval result set; a second retrieval result set determination module, used to initialize a second retrieval result set, and based on the similarity of each of the first retrieval results in the first retrieval result set and the similarity with the first retrieval result in the first retrieval result set, determine the first retrieval result set. The distance of the second search result set determines the second search result set; a splicing text matrix determination module is used to splice each second search result with the search text for each second search result in the second search result set, and determine the matrix corresponding to the spliced text, wherein the matrix includes text information and position information of the spliced text; a text rearrangement module is used to input the matrix, the heat feature and the timeliness feature of the second search result into a pre-trained text rearrangement model to obtain the positive score and the negative score of each second search result, and reorder the second search results according to the positive score and the negative score.
[0013] In an exemplary embodiment of the present disclosure, the first search result set determination module is specifically used to: for text newly entered into the knowledge base, record the entry time of the text, and set the initial value of the number of visits to the text to 0; when it is detected that the text is accessed, update the value of the number of visits; when the text is retrieved, determine the popularity feature of the text based on the number of visits, and determine the timeliness feature of the text based on the entry time and the current retrieval time.
[0014] In an exemplary embodiment of the present disclosure, the first retrieval result set determination module is also used to: determine the term frequency-inverse document frequency of each of the first retrieval results; calculate the weighted sum of the popularity feature, the timeliness feature and the term frequency-inverse document frequency of each of the first retrieval results according to preset weights, and determine the first retrieval result set based on the weighted sum.
[0015] In an exemplary embodiment of the present disclosure, the spliced text matrix determination module is specifically used to: calculate the cosine similarity between each of the first search results and the search text as the similarity of the first search result; move the first search result with the largest similarity to the second search result set; traverse the first search result set to calculate the distance from the remaining first search results in the first search result set to the second search result set; for each of the first search results, calculate the weighted sum of the similarity and the distance according to a preset weight, and move the first search result with the largest weighted sum to the second search result set; repeat the steps of traversing the first search result set to moving the first search result with the largest weighted sum to the second search result set until the first search result set is empty.
[0016] In an exemplary embodiment of the present disclosure, the concatenated text matrix determination module is specifically used to: input the concatenated text into the text retrieval model, and encode to obtain the sentence vector of the concatenated text; use the sorting number of the second retrieval result in the second retrieval result set as the position information; encode the sentence vector and the sorting number to obtain the matrix corresponding to the concatenated text.
[0017] In an exemplary embodiment of the present disclosure, the text rearrangement model is specifically used to: sort the second search results in descending order according to the positive scores; and sort the second search results with the same positive scores in ascending order according to the negative scores.
[0018] In an exemplary embodiment of the present disclosure, the text retrieval model also includes a model training module, which is specifically used to: obtain historical retrieval text, and determine the matrix of the historical retrieval text, the heat feature and the timeliness feature of the second retrieval result; obtain the number of likes and dislikes of the second retrieval result by the user, and logarithmically obtain the positive score and the negative score of the second retrieval result as training labels; train the network parameters of the pre-trained model based on the matrix, the heat feature and the timeliness feature; and correct the network parameters based on the training labels to obtain the text rearrangement model.
[0019] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to execute any one of the above-mentioned methods by executing the executable instructions.
[0020] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, any one of the methods described above is implemented.
[0021] The exemplary embodiments of the present disclosure may have some or all of the following beneficial effects:
[0022] In the text retrieval method provided in the example implementation of the present disclosure, a sentence vector of the retrieved text is generated through a pre-trained text retrieval model, and the above sentence vector is used to characterize the semantic features of the retrieved text; the popularity features and timeliness features of each text in the knowledge base are obtained, and based on the popularity features and timeliness features, the first retrieval result corresponding to the sentence vector is retrieved in the knowledge base to obtain a first retrieval result set; the second retrieval result set is initialized, and the second retrieval result set is determined based on the similarity of each first retrieval result in the first retrieval result set and the distance with the second retrieval result set; for each second retrieval result in the second retrieval result set, each second retrieval result is spliced with the retrieval text, and a matrix corresponding to the spliced text is determined, and the above matrix includes text information and position information of the spliced text; the matrix, the popularity features and timeliness features of the second retrieval result are input into a pre-trained text rearrangement model to obtain positive scores and negative scores of each second retrieval result, and the second retrieval results are reordered according to the positive scores and negative scores. The present invention obtains a first search result set based on popularity features and timeliness features, adjusts the order of the first search results in the first search result set by similarity and distance to a second search set, and finally reorders the texts in the second search result set based on a pre-trained text rearrangement model, comprehensively considering user preferences, popularity features and timeliness of texts, mutual influences between each text and other features, thereby meeting the requirements of text retrieval such as matching, professionalism and timeliness.
[0023] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification are used to explain the principles of the present disclosure. Obviously, the accompanying drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without creative work.
[0025] Figure 1 A schematic diagram of a flow chart of a text retrieval method according to an embodiment of the present disclosure is shown;
[0026] Figure 2 A schematic diagram schematically shows an application scenario of a text retrieval model of a text retrieval method according to an embodiment of the present disclosure;
[0027] Figure 3 A schematic diagram of a retrieval task of a text retrieval model of a text retrieval method according to an embodiment of the present disclosure is schematically shown;
[0028] Figure 4 A block diagram of a text retrieval device according to an embodiment of the present disclosure is schematically shown;
[0029] Figure 5 A schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0030] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0031] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0032] Text retrieval is a classic problem in natural language processing, which mainly studies the semantic similarity of two texts. The existing technology usually implements the text retrieval process through the following steps: according to the standard vector of the preset corpus, the word segmentation text set of the text to be retrieved is vectorized and encoded to obtain the vector of the word segmentation text set; the cosine similarity between the text to be retrieved and the text to be detected is calculated, the address of the text to be detected corresponding to the highest cosine similarity vector is obtained, and the target text is obtained according to the address of the text to be detected.
[0033] However, the above methods do not comprehensively consider characteristics such as user preferences for historical search texts, the popularity of search texts, user ratings of search texts, the mutual influence between each text, and the timeliness of search texts. They lack user-personalized text search methods and cannot meet the requirements of text retrieval for matching, professionalism, and timeliness in scenarios such as daily operation and maintenance of network clouds.
[0034] In order to solve the problems existing in the above methods, the embodiments of the present disclosure provide a text retrieval method, a text retrieval device, an electronic device and a computer-readable storage medium.
[0035] The following is a detailed description of the embodiments of the present disclosure:
[0036] This example implementation first provides a text retrieval method. Figure 1 As shown, the text retrieval method specifically includes the following steps:
[0037] Step S110: Generate a sentence vector of the search text through a pre-trained text search model, where the sentence vector is used to represent the semantic features of the search text;
[0038] Step S120: Obtain the popularity feature and timeliness feature of each text in the knowledge base, and search the knowledge base for a first search result corresponding to the sentence vector based on the popularity feature and timeliness feature to obtain a first search result set;
[0039] Step S130: Initialize the second search result set, and determine the second search result set based on the similarity of each first search result in the first search result set and the distance with the second search result set;
[0040] Step S140: for each second search result in the second search result set, concatenate each second search result with the search text, and determine a matrix corresponding to the concatenated text, wherein the matrix includes text information and position information of the concatenated text;
[0041] Step S150: Input the matrix, the heat features and the timeliness features of the second search results into a pre-trained text rearrangement model to obtain the positive score and the negative score of each second search result, and reorder the second search results according to the positive score and the negative score.
[0042] The text retrieval method provided by the embodiment of the present disclosure obtains a first retrieval result set based on popularity features and timeliness features, adjusts the order of the first retrieval results in the first retrieval result set by similarity and distance to the second retrieval set, and finally reorders the texts in the second retrieval result set based on a pre-trained text rearrangement model, comprehensively considering user preferences, popularity features and timeliness of texts, mutual influences between each text and other features, thereby meeting the requirements of matching, professionalism, timeliness and other requirements of text retrieval.
[0043] Next, in another embodiment, the above steps are described in more detail.
[0044] In step S110, a sentence vector of the search text is generated by a pre-trained text search model, and the sentence vector is used to represent the semantic features of the search text.
[0045] In the disclosed embodiment, the above search text is a text input by a user, and the user can search for the text to be obtained in the knowledge base through the input text. For example, the above search text can be a question input by a user, and the answer to the input question can be searched in the knowledge base.
[0046] In order to improve the versatility of the text retrieval method provided by the embodiment of the present disclosure, the vocabulary in the above knowledge base can be expanded according to the actual application scenario. Exemplarily, the process can be implemented as follows: obtain the vocabulary of the field corresponding to the current application scenario; add the above vocabulary to the knowledge base, and normalize the vocabulary.
[0047] Taking the network cloud operation and maintenance scenario as an example, the network cloud operation and maintenance scenario involves a vast amount of network cloud field knowledge, including but not limited to industry specifications, Chinese and English professional vocabulary, etc. In addition, as a new business scenario, network cloud has many professional terms that are not fixed like traditional industry information. With the development of technology, many new professional terms and standard entries will continue to be derived. In order to adapt to the network cloud operation and maintenance scenario, the disclosed embodiment can construct a large-scale professional vocabulary for network cloud operation and maintenance scenarios, that is, the above-mentioned knowledge base, mainly extracting relevant vocabulary from a large number of professional books, and constructing the above-mentioned knowledge base based on the relationship context of Chinese and English correspondence, abbreviation correspondence, synonyms, antonyms, etc. Exemplarily, the above-mentioned knowledge base can be constructed in the form of a graph, and its construction process may include the following steps: entity definition according to business, entity recognition, entity-relationship extraction, and entity normalization. Among them, the above-mentioned entities are network cloud professional vocabulary entities, and the relationships between entities include English descriptions, English abbreviations, synonyms, antonyms, inclusion, etc. The above entity normalization is specifically implemented as follows: using a trained entity recognition model to extract several candidate entities from the text; using a relationship extraction algorithm to obtain the relationship between entities; and normalizing the entities for the synonymous / abbreviation / Chinese-English correspondence between two entities. In a specific embodiment, the result of entity normalization can be shown in Table 1 below:
[0048] Table 1:
[0049]
[0050] It should be noted that the above scenario is only an exemplary description, and the protection scope of the embodiments of the present disclosure is not limited thereto.
[0051] In the disclosed embodiment, the above text retrieval model is used to obtain the sentence vector of the retrieved text. Taking the above network cloud operation and maintenance scenario as an example, the disclosed embodiment can add the obtained network cloud professional vocabulary to the vocabulary library of the BERT model based on the open source pre-trained BERT model weights for general fields, and then retrain 3 rounds using the corpus in the network cloud operation and maintenance field, with the aim of enabling the BERR model to learn the semantic and grammatical features of the professional vocabulary in this field.
[0052] Specifically, the process of constructing the text retrieval model SimBERT based on the BERT model can be as follows: since the [CLS] vector can effectively represent the sentence features, a sentence vector matrix V can be formed by the [CLS] vectors in the entire batch (sliced data set); the vector matrix V is normalized and then inner products are performed pairwise, and the diagonal part is masked; softmax nonlinearization is performed on each row of the matrix.
[0053] The essence of the above process is to train each batch of samples as a classification task, and the target label of each sample is its similar sentence (which has been shielded). Then, based on thousands of similar questions provided in the field,<question1,question2> Train the text retrieval model. In the application stage, generate sentence vectors for the text input by the user based on this model. The sentence vectors can effectively represent the semantic knowledge of the text input by the user.
[0054] by Figure 2 For example, the input of the above training Simbert model is:
[0055] <cls>+<Text 1>+ <sep>+<Text 2>+ <sep>
[0056] Among them, cls represents the beginning of the sentence, sep represents the end of the sentence, and the CLS position can be used as the sentence vector representation of <text 1>.
[0057] In the above training process, the training corpus is similar sentence pairs collected by ourselves. The Seq2Seq part is constructed by using one sentence to predict the similar sentence generation task of another sentence. The vector of [CLS] represents the input sentence vector. In addition, the above training process can also train a retrieval task at the same time. This retrieval task treats all non-similar samples in the batch as negative samples, and uses softmax (probability between 1 and 0) to increase the similarity of the samples and reduce the similarity of the remaining samples. The output vector of the model Simbert obtained by training at the CLS position is as follows: Figure 3 As shown, the semantic information of a sentence can be effectively described in the semantic vector space. It should be noted that the above scenario is only an exemplary description, and the protection scope of the embodiment of the present disclosure is not limited thereto.
[0058] After the text retrieval model is trained through the above process, the embodiment of the present disclosure can input the retrieval text into the pre-trained text retrieval model to generate a sentence vector for the retrieval text.
[0059] In step S120, the popularity feature and timeliness feature of each text in the knowledge base are obtained, and based on the popularity feature and timeliness feature, the first search result corresponding to the sentence vector is searched in the knowledge base to obtain a first search result set.
[0060] In the embodiments of the present disclosure, illustratively, the above-mentioned heat feature can be determined by the number of times the user visits the text, and the above-mentioned timeliness feature can be determined by the storage time of the text and the current search time. Exemplarily, the above-mentioned heat feature and timeliness feature can be determined by the following process: for text newly added to the knowledge base, record the storage time of the text, and set the initial value of the number of times the text is visited to 0; when it is detected that the text is visited, update the value of the number of visits; when the text is retrieved, determine the heat feature of the text based on the number of visits, and determine the timeliness feature of the text based on the storage time and the current search time.
[0061] After determining the popularity features and timeliness features, the present disclosure can further determine the above-mentioned first search result set as follows: determine the term frequency-inverse document frequency of each first search result; calculate the weighted sum of the popularity features, timeliness features and term frequency-inverse document frequency of each first search result according to preset weights, and determine the first search result set based on the weighted sum.
[0062] Taking the above network cloud operation and maintenance scenario as an example, considering that the knowledge points in the network cloud scenario are frequently updated, in order to solve the problem that the recall results are fixed for the same user input in the prior art, the disclosed embodiment combines the timeliness and popularity characteristics of the text to optimize the recall strategy, which not only makes the recall results more inclined to the newly added / updated and recently frequently acquired knowledge points, but also improves the dynamic change characteristics of the returned results when the user input and knowledge base remain unchanged.
[0063] The timeliness feature can be fitted by a linear function, an exponential function or a Gaussian function. Preferably, since the Gaussian function is bell-shaped, the decay rate is first slow, then accelerated, and then slow. In the disclosed embodiment, a Gaussian function can be selected to model timeliness. Specifically, the process of determining the heat feature and timeliness feature of each text in the knowledge base can be as follows:
[0064] S1: For the newly stored text, set its access count a to 0 and record its storage time in_time.
[0065] S2: Every time the user clicks to view the text, update a to a+1.
[0066] S3: Model the number of clicks and timeliness according to the following formulas 1 and 2 respectively to generate the heat feature and timeliness feature of the text. The purpose of logarithmization in formula 3 is to compress the fluctuation space of a and eliminate heteroscedasticity. The parameter now_time in formula 2 is the user's current search time, and offset is the minimum time offset of the decay function. Formula 2 gives the variance formula of formula 3. Among them, scale represents the basic unit time, such as 1 day. decay represents the decay value per unit time. Formula 4 gives the final formula, where tf is the word frequency and idf is the inverse text frequency index.
[0067] a=log(0.1*a+1) (Formula 1)
[0068]
[0069] σ 2 =-scale 2 / (2*ln(decay)) (Formula 3)
[0070] s=w 1 *a+w 2 *t+w 3 *tf*idf;w 1 +w 2 +w 3 =1 (Formula 4)
[0071] According to the improved recall strategy described above, the disclosed embodiment obtains a set of coarse-grained result sets that compromise text relevance, text popularity, and timeliness, that is, the first search result set obtained above.
[0072] It should be noted that the above scenario is only an exemplary description, and the protection scope of the embodiments of the present disclosure is not limited thereto.
[0073] In step S130, the second search result set is initialized, and the second search result set is determined based on the similarity of each first search result in the first search result set and the distance between the first search result and the second search result set.
[0074] In the disclosed embodiment, after determining the first search result set, the first search result can be further sorted according to the similarity and diversity optimization of the text. Exemplarily, the similarity of the first search result can be determined according to the cosine similarity between the first search result and the search text, and the process of the diversity optimization can be determined based on the distance between the first search result and the second search result. The above-mentioned determination of the second search result set based on the similarity of each first search result in the first search result set and the distance to the second search result set can be implemented as follows: calculate the cosine similarity between each first search result and the search text as the similarity of the first search result; move the first search result with the largest similarity to the second search result set; traverse the first search result set, and calculate the distance from the remaining first search results in the first search result set to the second search result set; for each first search result, calculate the weighted sum of the similarity and the distance according to the preset weight, and move the first search result with the largest weighted sum to the second search result set; repeat the steps of "traversing the first search result set" to "moving the first search result with the largest weighted sum to the second search result set" until the first search result set is empty.
[0075] Taking the above network cloud operation and maintenance scenario as an example, network cloud operation and maintenance involves dozens of business scenarios, such as performance, capacity, etc. The boundaries of each business are not obvious. In other words, they are independent of each other, but they may have certain commonalities. Therefore, when conducting retrieval evaluation, it is necessary to consider the correlation between businesses, that is, to achieve the above refined sorting process based on the similarity and diversity of each text to be retrieved.
[0076] In a specific embodiment, the above process can be implemented as follows:
[0077] S1: After obtaining the sentence vector representation through the above-mentioned trained text retrieval model for network cloud operation and maintenance scenarios, use Formula 5 to calculate the cosine similarity between each first search result and the search text.
[0078]
[0079] S2: Initialize the diversity result set (i.e. the second search result set mentioned above) S * ={}, and sort the first search result set S in descending order according to probability.
[0080] S3: Select the S with the largest cosine similarity from the first search result set S 0 , incorporated into S * , that is, S * ={S 0 }.
[0081] S4: Traverse the remaining elements in the first search result set S and calculate the i The distance S to the second search result set * , the distance is calculated as in Formula 6, where n is the set S * The number of elements of . The larger the value, the higher the S i Follow the set S * The greater the difference, the more it should be included in the set S * .
[0082]
[0083] S5: Comprehensive consideration i The similarity and S i To set S * distance, select the maximum score Score i The corresponding S i Leave set S, enter set S * The comprehensive evaluation formula 7 is as follows, where W 1 and W 2 is the weight used to balance the similarity Sim i and diversity i .
[0084] Score i =W 1 *Sim i +W 2 *Distance i ;W 1 +W 2 =1 (Formula 7)
[0085] S6: Repeat steps S4 and S5 until the set S is empty and a new sequence S is obtained. * .
[0086] It should be noted that the above scenario is only an exemplary description, and the protection scope of the embodiments of the present disclosure is not limited thereto.
[0087] In step S140, for each second search result in the second search result set, each second search result is concatenated with the search text, and a matrix corresponding to the concatenated text is determined. The matrix includes text information and position information of the concatenated text.
[0088] In the disclosed embodiment, this step is used to concatenate the second search result and the search text to obtain a corresponding matrix, so as to subsequently rearrange the second search result set based on the matrix to improve the matching degree of the search results.
[0089] Exemplarily, the determination of the above-mentioned matrix can be achieved as follows: input the concatenated text into the above-mentioned text retrieval model, and encode the sentence vector of the concatenated text; use the sorting number of the second retrieval result in the second retrieval result set as position information; encode the sentence vector and the sorting number to obtain the matrix corresponding to the concatenated text.
[0090] Taking the above network cloud operation and maintenance scenario as an example, the process can be specifically implemented as follows: * Each candidate document d is concatenated with the user input text q and the above text retrieval model is used to<d,q> Encode into the corresponding vector pv, multiple documents can get the matrix PV; S * The sorting sequence number is used as the position code PE of the corresponding document; PV and PE are Transformer encoded to obtain a matrix H that combines document information and sorting position information. It should be noted that the above scenario is only an exemplary description, and the protection scope of the embodiment of the present disclosure is not limited to this.
[0091] In step S150, the matrix, the popularity features and the timeliness features of the second search results are input into a pre-trained text rearrangement model to obtain the positive score and the negative score of each second search result, and the second search results are reordered according to the positive score and the negative score.
[0092] In the disclosed embodiment, the text rearrangement model is used to obtain the positive score and negative score of the text, and reorder the second search result in combination with the positive score and the negative score.
[0093] Exemplarily, the training process of the above-mentioned text rearrangement model can be as follows: obtain historical search texts, and determine the matrix of the historical search texts, the heat features and timeliness features of the second search results; obtain the number of likes and dislikes of the second search results by users, and logarithmically obtain the positive and negative scores of the second search results as training labels; train the network parameters of the pre-trained model based on the matrix, heat features and timeliness features; correct the network parameters based on the training labels to obtain the text rearrangement model.
[0094] After obtaining the above text rearrangement model, the second search results can be rearranged based on the output of the text rearrangement model. Exemplarily, the rearrangement process can be as follows: the second search results are sorted in descending order according to the positive scores; for the second search results with the same positive scores, they are sorted in ascending order according to the negative scores.
[0095] Taking the above network cloud operation and maintenance scenario as an example, the training of the above text rearrangement model and the reordering of the second search results can be specifically implemented as follows:
[0096] Combined with the characteristics of network cloud scenarios, a text rearrangement model is trained based on the Transformer model.
[0097] Construct model input: For S * Each candidate document d is concatenated with the user input text q and the above text retrieval model is used to<d,q> Encode into the corresponding vector pv, multiple documents can get the matrix PV; S * The sorting number is used as the position code PE of the corresponding document. After Transformer encoding is performed on PV and PE to obtain a matrix H that combines document information and sorting position information, the document timeliness feature t, heat feature a and the above matrix H obtained in step S120 are used as model input.
[0098] Constructing model labels: This specific embodiment constructs labels based on the historical records of the number of times users like or dislike a text. The specific implementation is: the number of likes and dislikes of the document by the user under the same user input is counted separately, and the positive score p_score and negative score n_score of each document are obtained logarithmically as model labels.
[0099] Training process: The network parameters in Formula 8 and Formula 9 are trained according to the above model input and model label to obtain the above text rearrangement model, so as to predict the forward score and reverse score of each search result through the text rearrangement model. Formula 8 and Formula 9 are as follows, where W p ,W n ,W t and W a are trainable network parameters.
[0100]
[0101]
[0102] The trained text rearrangement model can predict S * After obtaining the positive and negative scores of each document in the sequence, this specific embodiment first sorts the documents in descending order according to the positive dimension, and sorts the documents with consistent positive scores in ascending order according to the negative dimension to obtain the final result sequence S'.
[0103] It should be noted that the above scenario is only an exemplary description, and the protection scope of the embodiments of the present disclosure is not limited thereto.
[0104] It should be noted that although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0105] Correspondingly, in this example implementation, a text retrieval device is also provided, referring to Figure 4 As shown, the text search device 400 may include a vector generation module 410, a first search result set determination module 420, a second search result set determination module 430, a concatenated text matrix determination module 440, and a text rearrangement module 450, wherein:
[0106] The vector generation module 410 may be used to generate a sentence vector of the search text using a pre-trained text search model, wherein the sentence vector is used to represent the semantic features of the search text;
[0107] The first search result set determination module 420 may be used to obtain the popularity feature and timeliness feature of each text in the knowledge base, and search the knowledge base for the first search result corresponding to the sentence vector based on the popularity feature and timeliness feature to obtain the first search result set;
[0108] The second search result set determination module 430 may be used to initialize the second search result set and determine the second search result set based on the similarity of each first search result in the first search result set and the distance with the second search result set;
[0109] The concatenated text matrix determination module 440 may be used to concatenate each second search result in the second search result set with the search text, and determine a matrix corresponding to the concatenated text, the matrix including text information and position information of the concatenated text;
[0110] The text rearrangement module 450 can be used to input the above matrix, the popularity features and the timeliness features of the second search results into a pre-trained text rearrangement model, obtain the positive and negative scores of each second search result, and reorder the second search results according to the positive and negative scores.
[0111] In an exemplary embodiment of the present disclosure, the above-mentioned first search result set determination module is specifically used to: for text newly entered into the knowledge base, record the entry time of the text, and set the initial value of the number of visits to the text to 0; when it is detected that the text is accessed, update the value of the number of visits; when the text is retrieved, determine the popularity feature of the text based on the number of visits, and determine the timeliness feature of the text based on the entry time and the current retrieval time.
[0112] In an exemplary embodiment of the present disclosure, the above-mentioned first search result set determination module is also used to: determine the term frequency-inverse document frequency of each first search result; calculate the weighted sum of the popularity characteristics, timeliness characteristics and term frequency-inverse document frequency of each first search result according to preset weights, and determine the first search result set based on the weighted sum.
[0113] In an exemplary embodiment of the present disclosure, the above-mentioned spliced text matrix determination module is specifically used to: calculate the cosine similarity between each first search result and the search text as the similarity of the first search result; move the first search result with the largest similarity to the second search result set; traverse the first search result set, and calculate the distance from the remaining first search results in the first search result set to the second search result set; for each first search result, calculate the weighted sum of the similarity and the distance according to the preset weight, and move the first search result with the largest weighted sum to the second search result set; repeat the step of traversing the first search result set to move the first search result with the largest weighted sum to the second search result set until the first search result set is empty.
[0114] In an exemplary embodiment of the present disclosure, the above-mentioned spliced text matrix determination module is specifically used to: input the spliced text into a text retrieval model, encode and obtain a sentence vector of the spliced text; use the sorting number of the second retrieval result in the second retrieval result set as position information; encode the sentence vector and the sorting number to obtain a matrix corresponding to the spliced text.
[0115] In an exemplary embodiment of the present disclosure, the above-mentioned text rearrangement model is specifically used to: sort the second search results in descending order according to the positive scores; and sort the second search results with the same positive scores in ascending order according to the negative scores.
[0116] In an exemplary embodiment of the present disclosure, the above-mentioned text retrieval model also includes a model training module, which is specifically used to: obtain historical retrieval text, and determine the matrix of the historical retrieval text, the popularity feature and timeliness feature of the second retrieval result; obtain the number of likes and dislikes of the second retrieval result by the user, and logarithmically obtain the positive score and negative score of the second retrieval result as training labels; train the network parameters of the pre-trained model based on the matrix, popularity feature and timeliness feature; correct the network parameters based on the training labels to obtain a text rearrangement model.
[0117] In addition, the specific implementation details of the above-mentioned text retrieval device have been described in detail in the corresponding position of the text retrieval method, so they will not be repeated here.
[0118] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0119] Figure 5 Schematic diagram of the structure of an electronic device in the embodiment of the present disclosure. Figure 5 , which shows a structural schematic diagram of an electronic device 500 suitable for implementing the embodiments of the present disclosure. Figure 5 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0120] like Figure 5 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 to a random access memory (RAM) 503 to implement the text retrieval method of the embodiment described in the present disclosure. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0121] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5 The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0122] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains a program code for executing the method shown in the flowchart, thereby implementing the text retrieval method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are executed.
[0123] It should be noted that the computer-readable medium disclosed above may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in combination with an instruction execution system, device or device. In the present disclosure, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, in which a computer-readable program code is carried. This propagated data signal may take a variety of forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0124] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperText Transfer Protocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0125] The computer-readable medium may be included in the electronic device, or may exist independently without being installed in the electronic device.
[0126] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0127] Generate sentence vectors of the retrieved text through a pre-trained text retrieval model. The sentence vectors are used to represent the semantic features of the retrieved text.
[0128] Obtaining the popularity feature and timeliness feature of each text in the knowledge base, and searching the knowledge base for a first search result corresponding to the sentence vector based on the popularity feature and timeliness feature to obtain a first search result set;
[0129] Initializing a second search result set, and determining a second search result set based on the similarity of each first search result in the first search result set and the distance between the first search result and the second search result set;
[0130] For each second search result in the second search result set, concatenate each second search result with the search text, and determine a matrix corresponding to the concatenated text, the matrix including text information and position information of the concatenated text;
[0131] The matrix, the popularity features and the timeliness features of the second search results are input into a pre-trained text rearrangement model to obtain the positive and negative scores of each second search result, and the second search results are reordered according to the positive and negative scores.
[0132] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0133] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0134] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0135] The units involved in the embodiments described in the present disclosure may be implemented by software or hardware, wherein the name of a unit does not, in some cases, limit the unit itself.
[0136] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0137] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0138] The above description is only a preferred embodiment of the present disclosure and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present disclosure (but not limited to) by each other to form a technical solution.
[0139] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0140] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.< / sep> < / sep> < / cls>
Claims
1. A text retrieval method, characterized in that: include: Generate a sentence vector of the search text through a pre-trained text search model, wherein the sentence vector is used to represent the semantic features of the search text; Obtaining a popularity feature and a timeliness feature of each text in a knowledge base, and searching the knowledge base for a first search result corresponding to the sentence vector based on the popularity feature and the timeliness feature to obtain a first search result set; Initializing a second search result set, and determining the second search result set based on the similarity of each of the first search results in the first search result set and the distance between the first search result set and the second search result set; For each second search result in the second search result set, concatenate each second search result with the search text, and determine a matrix corresponding to the concatenated text, wherein the matrix includes text information and position information of the concatenated text; The matrix, the popularity feature and the timeliness feature of the second search results are input into a pre-trained text rearrangement model to obtain positive scores and negative scores of each second search result, and the second search results are reordered according to the positive scores and the negative scores.
2. The text retrieval method according to claim 1, characterized in that: The method of obtaining the popularity feature and timeliness feature of each text in the knowledge base includes: For a text newly added to the knowledge base, the entry time of the text is recorded, and the initial value of the number of accesses to the text is set to 0; When it is detected that the text is accessed, updating the value of the access times; When the text is retrieved, the popularity feature of the text is determined based on the number of accesses, and the timeliness feature of the text is determined based on the storage time and the current retrieval time.
3. The text retrieval method according to claim 2, characterized in that: The step of searching the knowledge base for a first search result corresponding to the sentence vector based on the popularity feature and the timeliness feature to obtain a first search result set includes: Determining a term frequency-inverse document frequency of each of the first search results; The weighted sum of the popularity feature, the timeliness feature and the term frequency-inverse document frequency of each of the first search results is calculated according to preset weights, and the first search result set is determined according to the weighted sum.
4. The text retrieval method according to claim 1, characterized in that: The determining the second search result set based on the similarity of each of the first search results in the first search result set and the distance between the first search result set and the second search result set includes: Calculating the cosine similarity between each of the first search results and the search text as the similarity of the first search result; Move the first search result with the greatest similarity to the second search result set; Traversing the first search result set, and calculating the distances from the remaining first search results in the first search result set to the second search result set; For each of the first search results, calculate the weighted sum of the similarity and the distance according to a preset weight, and move the first search result with the largest weighted sum to the second search result set; The step of traversing the first search result set to moving the first search result with the largest weighted sum to the second search result set is repeated until the first search result set is empty.
5. The text retrieval method according to claim 1, characterized in that: The step of determining the matrix corresponding to the spliced text includes: Inputting the concatenated text into the text retrieval model, and encoding to obtain a sentence vector of the concatenated text; Using the sorting sequence number of the second search result in the second search result set as the position information; The sentence vector and the sorting sequence number are encoded to obtain the matrix corresponding to the concatenated text.
6. The text retrieval method according to claim 1, characterized in that: The reordering of the second search results according to the positive scores and the negative scores includes: Arrange the second search results in descending order according to the positive scores; The second search results having the same positive scores are sorted in ascending order according to the negative scores.
7. The text retrieval method according to claim 1, characterized in that: The training method of the text rearrangement model comprises: Acquire historical search text, and determine the matrix of the historical search text, the popularity feature and the timeliness feature of the second search result; Obtain the number of likes and dislikes of the second search result by the user, and logarithmically obtain the positive score and the negative score of the second search result as training labels; Training network parameters of a pre-trained model according to the matrix, the heat feature, and the timeliness feature; The network parameters are modified according to the training labels to obtain the text rearrangement model.
8. The text retrieval method according to claim 1, characterized in that: Before generating the sentence vector of the retrieved text by using the pre-trained text retrieval model, the method further includes: Get the vocabulary corresponding to the field of the current application scenario; The vocabulary is added to the knowledge base and the vocabulary is normalized.
9. A text retrieval device, characterized in that: include: A vector generation module, used to generate a sentence vector of the search text through a pre-trained text search model, wherein the sentence vector is used to represent the semantic features of the search text; A first search result set determination module, configured to obtain a popularity feature and a timeliness feature of each text in a knowledge base, and to search the knowledge base for a first search result corresponding to the sentence vector based on the popularity feature and the timeliness feature to obtain a first search result set; A second search result set determination module, used for initializing a second search result set, and determining the second search result set based on the similarity of each of the first search results in the first search result set and the distance to the second search result set; A concatenated text matrix determination module, for concatenating each second search result in the second search result set with the search text, and determining a matrix corresponding to the concatenated text, wherein the matrix includes text information and position information of the concatenated text; A text rearrangement module is used to input the matrix, the heat feature and the timeliness feature of the second search result into a pre-trained text rearrangement model to obtain the positive score and the negative score of each second search result, and reorder the second search results according to the positive score and the negative score.
10. The text search device according to claim 9, characterized in that: The first search result set determination module is specifically used for: For a text newly added to the knowledge base, the entry time of the text is recorded, and the initial value of the number of accesses to the text is set to 0; When it is detected that the text is accessed, updating the value of the access times; When the text is retrieved, the popularity feature of the text is determined based on the number of visits, and the timeliness feature of the text is determined based on the storage time and the current search time.
11. The text search device according to claim 10, characterized in that: The first search result set determination module is further configured to: Determining a term frequency-inverse document frequency of each of the first search results; The weighted sum of the popularity feature, the timeliness feature and the term frequency-inverse document frequency of each of the first search results is calculated according to preset weights, and the first search result set is determined according to the weighted sum.
12. The text search device according to claim 9, characterized in that: The splicing text matrix determination module is specifically used for: Calculating the cosine similarity between each of the first search results and the search text as the similarity of the first search result; Move the first search result with the greatest similarity to the second search result set; Traversing the first search result set, and calculating the distances from the remaining first search results in the first search result set to the second search result set; For each of the first search results, calculate the weighted sum of the similarity and the distance according to a preset weight, and move the first search result with the largest weighted sum to the second search result set; The step of traversing the first search result set to moving the first search result with the largest weighted sum to the second search result set is repeated until the first search result set is empty.
13. The text search device according to claim 9, characterized in that: The splicing text matrix determination module is specifically used for: Inputting the concatenated text into the text retrieval model, and encoding to obtain a sentence vector of the concatenated text; Using the sorting sequence number of the second search result in the second search result set as the position information; The sentence vector and the sorting sequence number are encoded to obtain the matrix corresponding to the concatenated text.
14. The text retrieval model according to claim 9, characterized in that: The text rearrangement model is specifically used for: Arrange the second search results in descending order according to the positive scores; The second search results having the same positive scores are sorted in ascending order according to the negative scores.
15. The text retrieval model according to claim 9, characterized in that: The text retrieval model also includes a model training module, which is specifically used to: Acquire historical search text, and determine the matrix of the historical search text, the popularity feature and the timeliness feature of the second search result; Obtain the number of likes and dislikes of the second search result by the user, and logarithmically obtain the positive score and the negative score of the second search result as training labels; Training network parameters of a pre-trained model according to the matrix, the heat feature, and the timeliness feature; The network parameters are modified according to the training labels to obtain the text rearrangement model.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
17. An electronic device, characterized in that: include: processor; A memory, configured to store executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 8 by executing the executable instructions.
