Method, device, equipment and medium for training ranking model based on user retrieval
Through the sorting model training method based on user search, the sorting model is optimized by word segmentation and matrix conversion technology, and the problem of low correlation and accuracy of document sorting results is solved, and high-accuracy documents are achieved in the case of user search and cold start Sort.
Patent Information
- Application Number
- CN202210423251.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-21
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2042-04-21
AI Technical Summary
In the prior art, the document sorting results based on search content have low correlation and accuracy, especially when the user click-through rate is low or the system is cold-started, the accuracy of the sorting results is insufficient.
The sorting model training method based on user search is adopted, and the training search words and documents are obtained for word segmentation processing, and the preset sorting model is used for matrix conversion and vector internal product to optimize the sorting model to improve the accuracy of document sorting.
Through two sorting calculations and loss value optimization, the relevance and accuracy of document sorting are improved, ensuring the accuracy of document sorting results during user retrieval and under cold startup.
Smart Images

Figure CN114676307B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of model building, and in particular to a method, device, equipment and medium for training a ranking model based on user retrieval. Background Art
[0002] At present, many application platforms have search functions. When the platform returns search results based on the search statement (Query) entered by the user, it usually presents sorted search results. These search results can be news, web pages, advertisements and other documents. In the prior art, inverted index or semantic similarity calculation is generally used to retrieve documents. Although this method can solve most retrieval needs, there are still problems such as the relevance of document content and retrieval ranking are not matched enough, and the sorting results presented by the retrieval are not accurate enough; when the document sorting is based on the user's click rate and the search system is cold-started, the results presented by the document sorting based on the search content are less relevant and accurate. Summary of the invention
[0003] The present invention provides a method, device, equipment and medium for training a ranking model based on user retrieval, the main purpose of which is to solve the problem of low relevance and accuracy of results presented by document ranking based on search content.
[0004] To achieve the above object, the present invention provides a method for training a ranking model based on user retrieval, comprising:
[0005] Acquire a training search term and a search document corresponding to the training search term, perform word segmentation processing on the training search term and all public documents in a preset document set, and obtain a search word segmentation and a plurality of public document word segments;
[0006] Using a preset first ranking model, the search word and the plurality of public document word segments are encoded and matrix-converted to obtain a search matrix and a plurality of public document matrices;
[0007] Performing vector inner products of the search matrix and the plurality of document matrices respectively to obtain a plurality of inner product results, and sorting the plurality of public documents according to the inner product results to obtain a sorted set;
[0008] Performing text concatenation and vectorization on the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and performing text concatenation and vectorization on the training search terms and the search documents to obtain a concatenated search document vector;
[0009] Inputting the plurality of concatenated sorting document vectors and the concatenated retrieval document vector into a second sorting model respectively, and obtaining a first output result corresponding to the plurality of concatenated sorting document vectors and a second output result corresponding to the concatenated retrieval document vector;
[0010] A preset loss function is used to calculate multiple first output results and the second output results to obtain a loss value, and the second sorting model is optimized according to the loss value, and the optimized second sorting model and the first sorting model are output as standard sorting models.
[0011] Optionally, the segmentation processing of the training search term and all public documents in the preset document set to obtain the search segmentation and multiple public document segmentations includes:
[0012] Using a word segmenter to perform word segmentation processing on the training search term and all public documents in a preset document set, to obtain a first word segmentation corresponding to the training search term and a plurality of second word segmentations corresponding to the public documents;
[0013] Deleting specific participles of the first participle and the plurality of second participles according to a preset part-of-speech table and a stop word list, to obtain a first target participle corresponding to the training search term and a second target participle corresponding to the plurality of public documents;
[0014] Punctuation marks in the first target segmentation and the plurality of second target segmentations are deleted to obtain a search segmentation and a plurality of public document segmentations.
[0015] Optionally, the deleting specific participles of the first participle and the plurality of second participles according to a preset part-of-speech table and a stop word list to obtain a first target participle corresponding to the training search term and a plurality of second target participles corresponding to the public documents includes:
[0016] Obtain the part-of-speech tag to be deleted, and extract the corresponding participle in the part-of-speech table according to the part-of-speech tag to be deleted;
[0017] Extract the corresponding participle in the stop word list;
[0018] The same segmentations as the corresponding segmentations in the part-of-speech table and the corresponding segmentations in the stop word list are deleted from the first segmentation and the plurality of the second segmentations to obtain the first target segmentation and the plurality of the second target segmentations.
[0019] Optionally, the encoding and matrix conversion of the search word and the plurality of public document word segments by using a preset first ranking model to obtain a search matrix and a plurality of public document matrices includes:
[0020] Performing vector conversion on the search word and the plurality of public document word segments to obtain a first vector set and a plurality of second vector sets, and performing position encoding on the vectors in the first vector set and the plurality of second vector sets respectively to obtain a first positioning vector set corresponding to the search word and a second positioning vector set corresponding to the plurality of public document word segments;
[0021] The first positioning vector set and the plurality of second positioning vector sets are subjected to matrix transformation, and a retrieval matrix and a plurality of public document matrices are obtained based on the result of the matrix transformation, the first positioning vector set and the plurality of second positioning vector sets.
[0022] Optionally, the performing position encoding on the first vector set and the vectors in the plurality of second vector sets respectively comprises:
[0023] Extracting vectors from the first vector set and the plurality of second vector sets, and selecting vectors at preset positions from the first vector set and the plurality of second vector sets as coordinate origins;
[0024] According to the coordinate origin, a position vector of each vector is established, and the position vector is used to perform position encoding on the first vector set and the plurality of second vector sets.
[0025] Optionally, performing matrix transformation on the first positioning vector set and the plurality of second positioning vector sets, and calculating according to the result of the matrix transformation, the first positioning vector set and the plurality of second positioning vector sets to obtain a retrieval matrix and a plurality of common document matrices, comprises:
[0026] Convert the first positioning vector set and the plurality of second positioning vector sets into a first positioning vector matrix and a plurality of second positioning vector matrices, and generate a first classification iterative transformation matrix and a plurality of second classification iterative transformation matrices according to the dimensions of the first positioning vector matrix and the plurality of second positioning vector matrices;
[0027] Calculating using a pre-constructed exponential normalization function, the first positioning vector matrix, and the first classification iterative transformation matrix to obtain a first original vector correlation matrix corresponding to the first positioning vector set;
[0028] Calculating using the exponential normalization function, a plurality of the second positioning vector matrices, and a plurality of the second classification iterative transformation matrices to obtain a second original vector correlation matrix corresponding to the plurality of the second positioning vector sets;
[0029] Using the first original vector correlation matrix and the first positioning vector matrix, adjusting the iterative weight factor in the pre-constructed feedforward neural network to obtain a retrieval matrix;
[0030] The iterative weight factor is adjusted using a plurality of the second original vector correlation matrices and a corresponding plurality of the second positioning vector matrices to obtain a plurality of common document matrices.
[0031] Optionally, the text concatenation and vectorization of the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors includes:
[0032] Selecting a document from the sorted documents as a target document, and dividing the target document into a plurality of text segments;
[0033] Obtaining an average sentence length of the text segments, and scoring the plurality of text segments according to a preset semantic model and the training search terms;
[0034] splicing the target document and the training search term according to the average sentence length and the scoring result to obtain a target spliced document;
[0035] Perform word frequency statistics on the multiple text segments, set weights of the word segments in the multiple text segments according to the results of the word frequency statistics and the scoring results, and generate vector matrices of the multiple text segments according to the weights.
[0036] In order to solve the above problems, the present invention also provides a ranking model training device based on user retrieval, the device comprising:
[0037] A word segmentation generation module is used to obtain a training search term and a search document corresponding to the training search term, perform word segmentation processing on the training search term and all public documents in a preset document set, and obtain a search word segmentation and multiple public document word segments;
[0038] A vector matrix generation module, used for encoding and matrix conversion of the search word and the plurality of public document word segments by using a preset first ranking model to obtain a search matrix and a plurality of public document matrices;
[0039] A first sorting model calculation module is used to perform vector inner products on the search matrix and the plurality of document matrices respectively to obtain a plurality of inner product results, and sort the plurality of public documents according to the inner product results to obtain a sorted set;
[0040] A concatenated retrieval document vector generation module is used to perform text concatenation and vectorization on the training retrieval term and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and to perform text concatenation and vectorization on the training retrieval term and the retrieval document to obtain a concatenated retrieval document vector;
[0041] A second ranking model calculation module, used for inputting the plurality of concatenated ranking document vectors and the concatenated retrieval document vector into a second ranking model respectively, to obtain a first output result corresponding to the plurality of concatenated ranking document vectors and a second output result corresponding to the concatenated retrieval document vector;
[0042] The standard sorting module generation module is used to use a preset loss function to calculate multiple first output results and second output results to obtain a loss value, and optimize the second sorting model according to the loss value, and output the optimized second sorting model and the first sorting model as standard sorting models.
[0043] In order to solve the above problem, the present invention further provides an electronic device, the electronic device comprising:
[0044] at least one processor; and,
[0045] a memory communicatively connected to the at least one processor; wherein,
[0046] The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the above-mentioned user retrieval-based ranking model training method.
[0047] In order to solve the above problems, the present invention also provides a computer-readable storage medium, in which at least one computer program is stored. The at least one computer program is executed by a processor in an electronic device to implement the above-mentioned user retrieval-based ranking model training method.
[0048] The embodiment of the present invention performs a first calculation based on the search terms and the public documents in the document collection through the first ranking model, thereby realizing the initial ranking of the documents in the document collection, and performs a second calculation based on the search terms, the search documents and the ranked documents through the second ranking model, and then calculates the loss value based on the result of the second calculation, thereby optimizing the ranking model and improving the accuracy of the document ranking; the optimized model can realize two rankings based on the search terms, thereby ensuring the relevance and accuracy of the document ranking results during the normal user search process and in the absence of user clicks or system cold start. Therefore, the ranking model training method, device, electronic device and computer-readable storage medium based on user retrieval proposed in the present invention can solve the problem of low relevance and accuracy of the results presented by the document ranking based on the search content. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 A schematic diagram of a flow chart of a method for training a ranking model based on user retrieval provided in one embodiment of the present invention;
[0050] Figure 2 A schematic diagram of a process for generating search segmentation words and multiple public document segmentation words provided by an embodiment of the present invention;
[0051] Figure 3 A schematic diagram of a process of deleting a specific participle of a first participle and a plurality of second participles provided in an embodiment of the present invention;
[0052] Figure 4 A schematic diagram of a process for generating a search matrix and multiple public document matrices provided by an embodiment of the present invention;
[0053] Figure 5 A schematic diagram of a process for position encoding of a vector set provided by an embodiment of the present invention;
[0054] Figure 6 A schematic diagram of a process of performing matrix conversion on a vector set provided by an embodiment of the present invention;
[0055] Figure 7 A schematic diagram of a process for text concatenation and vectorization of training search terms and sorted documents provided in one embodiment of the present invention;
[0056] Figure 8 A functional module diagram of a user retrieval-based ranking model training device provided in one embodiment of the present invention;
[0057] Fig. 9 A schematic diagram of the structure of an electronic device for implementing the user retrieval-based ranking model training method provided in one embodiment of the present invention.
[0058] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0059] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0060] The embodiment of the present application provides a sorting model training method based on user retrieval. The execution subject of the sorting model training method based on user retrieval includes but is not limited to at least one of the electronic devices such as the server, the terminal, etc. that can be configured to execute the method provided by the embodiment of the present application. In other words, the sorting model training method based on user retrieval can be executed by software or hardware installed on a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to: a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be an independent server, or it can be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content distribution networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.
[0061] Reference Figure 1 FIG. 1 is a flow chart of a method for training a ranking model based on user retrieval provided by an embodiment of the present invention. In this embodiment, the method for training a ranking model based on user retrieval includes the following steps S1-S6:
[0062] S1. Obtain training search terms and search documents corresponding to the training search terms, perform word segmentation processing on the training search terms and all public documents in a preset document set, and obtain search word segments and multiple public document word segments.
[0063] In the embodiment of the present invention, the training search term may be a search keyword or a search sentence, and the search document corresponding to the training search term may be a matching document or an optimal document corresponding to the training search term.
[0064] In an embodiment of the present invention, a computer statement with a crawling function (such as a Java statement, a Python statement, etc.) can be used to obtain the training search terms and the search documents from a pre-constructed storage area for storing various types of training search terms and corresponding search documents. The storage area includes but is not limited to an image library, a blockchain node, a network cache, etc.
[0065] In the embodiment of the present invention, please refer to Figure 2 As shown, the word segmentation processing is performed on the training search term and all public documents in the preset document set to obtain the search word segmentation and multiple public document word segmentations, including the following steps S21-S23:
[0066] S21, using a word segmenter to perform word segmentation processing on the training search term and all public documents in a preset document set, to obtain a first word segmentation corresponding to the training search term and a plurality of second word segmentations corresponding to the public documents;
[0067] S22, deleting specific participles of the first participle and the plurality of second participles according to a preset part-of-speech table and a stop word list, to obtain a first target participle corresponding to the training search term and a second target participle corresponding to the plurality of public documents;
[0068] S23: Delete punctuation marks in the first target segmentation and the plurality of second target segmentations to obtain a search segmentation and a plurality of public document segmentations.
[0069] Specifically, see Figure 3 As shown, the method of deleting the first participle and a plurality of specific participles of the second participles according to the preset part-of-speech table and the stop word list to obtain the first target participle corresponding to the training search term and the second target participles corresponding to the plurality of public documents includes the following steps S31-S33:
[0070] S31, obtaining the part-of-speech tag to be deleted, and extracting the corresponding participle in the part-of-speech table according to the part-of-speech tag to be deleted;
[0071] S32, extracting the corresponding participles in the stop word list;
[0072] S33. Delete the same participle as the corresponding participle in the part-of-speech table and the corresponding participle in the stop word list from the first participle and the plurality of second participles to obtain the first target participle and the plurality of second target participles.
[0073] In the embodiment of the present invention, the word segmenter includes but is not limited to the Jieba word segmenter; the parts of speech in the part-of-speech table include adjectives, adverbs, etc.
[0074] S2. Encode and matrix-convert the search word and the plurality of public document word segments using a preset first ranking model to obtain a search matrix and a plurality of public document matrices.
[0075] In an embodiment of the present invention, the first sorting model includes but is not limited to a neural network model and a BERT model; the search segmentation words and the multiple public documents are encoded and matrix-converted through the first sorting model, thereby further realizing the initial sorting of the multiple public documents.
[0076] In the embodiment of the present invention, please refer to Figure 4 As shown, the use of a preset first ranking model to encode and matrix-convert the search word segment and the plurality of public document segment to obtain a search matrix and a plurality of public document matrices includes the following steps S41-S42:
[0077] S41, performing vector conversion on the search word and the plurality of public document word segments to obtain a first vector set and a plurality of second vector sets, and performing position encoding on the vectors in the first vector set and the plurality of second vector sets respectively to obtain a first positioning vector set corresponding to the search word and a second positioning vector set corresponding to the plurality of public document word segments;
[0078] S42: Perform matrix transformation on the first positioning vector set and the plurality of second positioning vector sets, and calculate based on the result of the matrix transformation, the first positioning vector set and the plurality of second positioning vector sets to obtain a retrieval matrix and a plurality of public document matrices.
[0079] Specifically, the embodiment of the present invention may adopt the Word2vec algorithm to perform vector conversion on all the search segmentations and the multiple public document segmentations.
[0080] For further information, see Figure 5 As shown, the position encoding of the vectors in the first vector set and the plurality of vectors in the second vector sets respectively comprises the following steps S51-S52:
[0081] S51, extracting vectors from the first vector set and multiple second vector sets, and selecting vectors at preset positions from the first vector set and multiple second vector sets respectively as coordinate origins;
[0082] S52. Establish a position vector for each vector according to the coordinate origin, and use the position vector to perform position encoding on the first vector set and multiple second vector sets.
[0083] Specifically, in the embodiment of the present invention, the farther a vector is from a vector at a preset position, the larger the modulus of the position vector corresponding to the vector is.
[0084] In the embodiment of the present invention, please refer to Figure 6 As shown, performing matrix transformation on the first positioning vector set and the plurality of second positioning vector sets, and calculating according to the result of the matrix transformation, the first positioning vector set and the plurality of second positioning vector sets to obtain a retrieval matrix and a plurality of public document matrices includes the following steps S61-S65:
[0085] S61, converting the first positioning vector set and the plurality of second positioning vector sets into a first positioning vector matrix and a plurality of second positioning vector matrices, and generating a first classification iterative transformation matrix and a plurality of second classification iterative transformation matrices according to the dimensions of the first positioning vector matrix and the plurality of second positioning vector matrices;
[0086] S62: Calculate using a pre-constructed exponential normalization function, the first positioning vector matrix, and the first classification iterative transformation matrix to obtain a first original vector correlation matrix corresponding to the first positioning vector set;
[0087] S63, using the exponential normalization function, multiple second positioning vector matrices and multiple second classification iterative transformation matrices to calculate, to obtain a second original vector correlation matrix corresponding to multiple second positioning vector sets;
[0088] S64, using the first original vector correlation matrix and the first positioning vector matrix, adjusting the iterative weight factor in the pre-constructed feedforward neural network to obtain a retrieval matrix;
[0089] S65. Use a plurality of the second original vector correlation matrices and a corresponding plurality of the second positioning vector matrices to adjust the iterative weight factor to obtain a plurality of common document matrices.
[0090] In an embodiment of the present invention, the dimension of the classification iteration transformation matrix is the same as that of the positioning vector matrix. For example, if the dimension of the positioning vector matrix is m×n, the dimension of the generated classification iteration matrix is also m×n. In an embodiment of the present invention, a random method can be used to generate the classification iteration matrix.
[0091] In an embodiment of the present invention, the first original vector correlation matrix and the first positioning vector matrix can be summed and normalized to obtain a normalized vector correlation matrix; the normalized vector correlation matrix can be input into a pre-constructed feedforward neural network, and the normalized vector correlation matrix can be weighted using the iterative weight factor in the feedforward neural network to obtain the retrieval matrix.
[0092] Specifically, the summing and normalization refers to superimposing the first original vector correlation matrix and the first positioning vector matrix, and performing normalization processing on the superimposed vector matrix to map the values in the vector matrix to the interval of 0-1, so as to facilitate the adjustment of the feedforward neural network.
[0093] In an embodiment of the present invention, the normalized vector correlation matrix is obtained by summing the first original vector correlation matrix and the first positioning vector matrix and then normalizing them. The normalization operation may be performed using a Layer Normalization function.
[0094] In an embodiment of the present invention, the process of using multiple second original vector correlation matrices and corresponding multiple second positioning vector matrices to adjust the iterative weight factor to obtain multiple common document matrices can be similar to the process of using the first original vector correlation matrix and the first positioning vector matrix to adjust the iterative weight factor in the pre-constructed feedforward neural network to obtain the retrieval matrix, which will not be elaborated here.
[0095] S3. Perform vector inner products on the search matrix and the multiple document matrices respectively to obtain multiple inner product results, and sort the multiple public documents according to the inner product results to obtain a sorted set.
[0096] In an embodiment of the present invention, before performing the vector inner product, the retrieval matrix and the question-answer matrix can be converted into matrices of the same dimension by padding with zeros or ones, and then the inner product results of each document matrix and the retrieval matrix can be calculated by a preset inner product operation method (for example, a dot multiplication operation).
[0097] Furthermore, the embodiment of the present invention can further indicate the relevance between the public document and the search term through the inner product result; and achieve the initial sorting of the public documents in the document collection through a preset sorting method, for example, by comparing the size of the inner product result.
[0098] S4. Text concatenation and vectorization are performed on the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and text concatenation and vectorization are performed on the training search terms and the search documents to obtain a concatenated search document vector.
[0099] In the embodiment of the present invention, please refer to Figure 7 As shown, the text concatenation and vectorization of the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors includes the following steps S71-S74:
[0100] S71, selecting a document from the sorted documents as a target document, and dividing the target document into multiple text segments;
[0101] S72, obtaining an average sentence length of the text segments, and scoring the multiple text segments according to a preset semantic model and the training search terms;
[0102] S73, splicing the target document and the training search term according to the average sentence length and the scoring result to obtain a target spliced document;
[0103] S74, performing word frequency statistics on the multiple text segments, setting weights of the word segments in the multiple text segments according to the results of the word frequency statistics and the scoring results, and generating vector matrices of the multiple text segments according to the weights.
[0104] Furthermore, the target document and the training search terms are spliced according to the average sentence length and the scoring results. The processed text segments are normalized in length according to the average sentence length to obtain the processed text segments; the processed text segments corresponding to the highest scores in the scoring results are obtained; and the processed text segments are spliced with the training search terms to obtain the target spliced document.
[0105] In the embodiment of the present invention, the speech model includes but is not limited to Deep Structured Semantic Models (DSSM) and Natural Language Processing Models (NPL).
[0106] In an embodiment of the present invention, in order to control the length of a text segment within a reasonable range, the type of punctuation mark corresponding to the current text segment can be determined according to the average sentence length. Among them, the types of punctuation marks can be divided into two types: first-class punctuation marks and second-class punctuation marks. When the average sentence length is long, you can consider setting a second-class punctuation mark for the current text segment to avoid long and difficult sentences in subsequent sentences; when the average sentence length is short, you can consider determining a first-class punctuation mark for the current text segment. The first-class punctuation marks may include: question marks, periods, exclamation marks, and ellipsis marks; the second-class punctuation marks may include: commas, colons, semicolons, colons, single quotation marks, and double quotation marks.
[0107] In the embodiment of the present invention, by text concatenating the training search terms and the sorted documents, the text content for the second sorting is more highly correlated with the training search terms, thereby making the results of the subsequent sorting by the second sorting model more accurate.
[0108] S5. Input the plurality of concatenated sorting document vectors and the concatenated retrieval document vector into a second sorting model respectively to obtain a first output result corresponding to the plurality of concatenated sorting document vectors and a second output result corresponding to the concatenated retrieval document vector.
[0109] In an embodiment of the present invention, the step of calculating the multiple concatenated sorting document vectors and the concatenated retrieval document vector through the second sorting model is similar to the step of calculating the training search terms and all public documents in the preset document set through the first sorting model in the above S1-S3, and will not be elaborated here.
[0110] S6. Calculate the first output results and the second output results using a preset loss function to obtain a loss value, optimize the second sorting model according to the loss value, and output the optimized second sorting model and the first sorting model as standard sorting models.
[0111] In the embodiment of the present invention, the loss values of the plurality of first output results and the second output results calculated by the loss function can be expressed by the following formula:
[0112]
[0113] Among them, LOSS is the loss value, τ is the preset hyperparameter, and t i is the i-th first output result, and s is the second output result.
[0114] In an embodiment of the present invention, the disease analysis model is optimized according to the joint loss value by judging whether the loss value is less than a preset loss threshold; when the loss value is greater than or equal to the preset loss threshold, the hyperparameters of the second sorting model are updated using a gradient descent algorithm, and the step of calculating the loss value and judging is returned; when the joint loss value is less than the preset loss threshold, the second sorting model and the first sorting model are output as standard sorting models.
[0115] The embodiment of the present invention performs a first calculation based on the search terms and the public documents in the document collection through the first ranking model, thereby realizing the initial ranking of the documents in the document collection, and performs a second calculation based on the search terms, the search documents and the ranked documents through the second ranking model, and then calculates the loss value based on the result of the second calculation, thereby optimizing the ranking model and improving the accuracy of the document ranking; the optimized model can realize two rankings based on the search terms, thereby ensuring the relevance and accuracy of the document ranking results during the normal user search process and in the absence of user clicks or system cold start. Therefore, the ranking model training method based on user retrieval proposed in the present invention can solve the problem of low relevance and accuracy of the results presented by the document ranking based on the search content.
[0116] like Figure 8 , which is a functional module diagram of a ranking model training device based on user retrieval provided by an embodiment of the present invention.
[0117] The user retrieval-based ranking model training device 100 of the present invention can be installed in an electronic device. According to the functions implemented, the user retrieval-based ranking model training device 100 can include a word segmentation generation module 101, a vector matrix generation module 102, a first ranking model calculation module 103, a spliced retrieval document vector generation module 104, a second ranking model calculation module 105 and a standard ranking module generation module 106. The module of the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.
[0118] In this embodiment, the functions of each module / unit are as follows:
[0119] The word segmentation generation module 101 is used to obtain a training search term and a search document corresponding to the training search term, perform word segmentation processing on the training search term and all public documents in a preset document set, and obtain a search word segmentation and a plurality of public document word segments;
[0120] The vector matrix generation module 102 is used to encode and matrix-convert the search word and the plurality of public document words using a preset first ranking model to obtain a search matrix and a plurality of public document matrices;
[0121] The first ranking model calculation module 103 is used to perform vector inner products on the search matrix and the multiple document matrices respectively to obtain multiple inner product results, and to sort the multiple public documents according to the inner product results to obtain a sorted set;
[0122] The concatenated search document vector generation module 104 is used to perform text concatenation and vectorization on the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and to perform text concatenation and vectorization on the training search terms and the search documents to obtain a concatenated search document vector;
[0123] The second ranking model calculation module 105 is used to input the plurality of concatenated ranking document vectors and the concatenated retrieval document vector into a second ranking model respectively, to obtain a first output result corresponding to the plurality of concatenated ranking document vectors and a second output result corresponding to the concatenated retrieval document vector;
[0124] The standard sorting module generation module 106 is used to calculate the multiple first output results and the second output results using a preset loss function to obtain a loss value, and optimize the second sorting model according to the loss value, and output the optimized second sorting model and the first sorting model as standard sorting models.
[0125] In detail, each module described in the user retrieval-based ranking model training device 100 in the embodiment of the present invention is used in the same manner as described above. Figures 1 to 7 The same technical means as the user retrieval-based ranking model training method described in , and can produce the same technical effects, will not be repeated here.
[0126] like Fig. 9 , is a schematic diagram of the structure of an electronic device for implementing a ranking model training method based on user retrieval provided by an embodiment of the present invention.
[0127] The electronic device 1 may include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and may also include a computer program stored in the memory 11 and executable on the processor 10, such as a ranking model training program based on user retrieval.
[0128] In some embodiments, the processor 10 may be composed of an integrated circuit, for example, a single packaged integrated circuit, or a plurality of packaged integrated circuits with the same or different functions, including one or more central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and combinations of various control chips. The processor 10 is the control core (ControlUnit) of the electronic device, and uses various interfaces and lines to connect various components of the entire electronic device, and executes or executes programs or modules stored in the memory 11 (for example, executing a ranking model training program based on user retrieval, etc.), and calls data stored in the memory 11 to execute various functions of the electronic device and process data.
[0129] The memory 11 includes at least one type of readable storage medium, and the readable storage medium includes a flash memory, a mobile hard disk, a multimedia card, a card-type memory (for example, an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 may be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 may also be an external storage device of an electronic device, such as a plug-in mobile hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the electronic device. Further, the memory 11 may also include both an internal storage unit of the electronic device and an external storage device. The memory 11 can not only be used to store application software and various types of data installed in the electronic device, such as the code of the sorting model training program based on user retrieval, but also can be used to temporarily store data that has been output or is to be output.
[0130] The communication bus 12 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. The bus is configured to realize connection and communication between the memory 11 and at least one processor 10, etc.
[0131] The communication interface 13 is used for communication between the above-mentioned electronic device and other devices, including a network interface and a user interface. Optionally, the network interface may include a wired interface and / or a wireless interface (such as a WI-FI interface, a Bluetooth interface, etc.), which is generally used to establish a communication connection between the electronic device and other electronic devices. The user interface may be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface may also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, and an OLED (Organic Light-Emitting Diode, organic light-emitting diode) touch device, etc. Among them, the display may also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visual user interface.
[0132] Fig. 9 Only an electronic device with components is shown, and those skilled in the art will understand that Fig. 9 The structure shown does not constitute a limitation on the electronic device 1, and may include fewer or more components than shown in the figure, or combine certain components, or arrange the components differently.
[0133] For example, although not shown, the electronic device may also include a power source (such as a battery) for supplying power to each component. Preferably, the power source may be logically connected to the at least one processor 10 through a power management device, so that the power management device can realize functions such as charging management, discharging management, and power consumption management. The power source may also include one or more DC or AC power sources, recharging devices, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components. The electronic device may also include a variety of sensors, Bluetooth modules, Wi-Fi modules, etc., which will not be repeated here.
[0134] It should be understood that the embodiment is for illustration only and the scope of the patent application is not limited to this structure.
[0135] The user retrieval-based ranking model training program stored in the memory 11 of the electronic device 1 is a combination of multiple instructions. When running in the processor 10, it can achieve:
[0136] Acquire a training search term and a search document corresponding to the training search term, perform word segmentation processing on the training search term and all public documents in a preset document set, and obtain a search word segmentation and a plurality of public document word segments;
[0137] Using a preset first ranking model, the search word and the plurality of public document word segments are encoded and matrix-converted to obtain a search matrix and a plurality of public document matrices;
[0138] Performing vector inner products of the search matrix and the plurality of document matrices respectively to obtain a plurality of inner product results, and sorting the plurality of public documents according to the inner product results to obtain a sorted set;
[0139] Performing text concatenation and vectorization on the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and performing text concatenation and vectorization on the training search terms and the search documents to obtain a concatenated search document vector;
[0140] Inputting the plurality of concatenated sorting document vectors and the concatenated retrieval document vector into a second sorting model respectively, and obtaining a first output result corresponding to the plurality of concatenated sorting document vectors and a second output result corresponding to the concatenated retrieval document vector;
[0141] A preset loss function is used to calculate multiple first output results and the second output results to obtain a loss value, and the second sorting model is optimized according to the loss value, and the optimized second sorting model and the first sorting model are output as standard sorting models.
[0142] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the relevant steps in the corresponding embodiment of the accompanying drawings, which will not be repeated here.
[0143] Furthermore, if the module / unit integrated in the electronic device 1 is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. The computer-readable storage medium can be volatile or non-volatile. For example, the computer-readable medium can include: any entity or device capable of carrying the computer program code, a recording medium, a USB flash drive, a mobile hard disk, a magnetic disk, an optical disk, a computer memory, and a read-only memory (ROM).
[0144] The present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor of an electronic device, the computer program can implement:
[0145] Acquire a training search term and a search document corresponding to the training search term, perform word segmentation processing on the training search term and all public documents in a preset document set, and obtain a search word segmentation and a plurality of public document word segments;
[0146] Using a preset first ranking model, the search word and the plurality of public document word segments are encoded and matrix-converted to obtain a search matrix and a plurality of public document matrices;
[0147] Performing vector inner products of the search matrix and the plurality of document matrices respectively to obtain a plurality of inner product results, and sorting the plurality of public documents according to the inner product results to obtain a sorted set;
[0148] Performing text concatenation and vectorization on the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and performing text concatenation and vectorization on the training search terms and the search documents to obtain a concatenated search document vector;
[0149] Inputting the plurality of concatenated sorting document vectors and the concatenated retrieval document vector into a second sorting model respectively, and obtaining a first output result corresponding to the plurality of concatenated sorting document vectors and a second output result corresponding to the concatenated retrieval document vector;
[0150] A preset loss function is used to calculate multiple first output results and the second output results to obtain a loss value, and the second sorting model is optimized according to the loss value, and the optimized second sorting model and the first sorting model are output as standard sorting models.
[0151] In the several embodiments provided by the present invention, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the modules is only a logical function division, and there may be other division methods in actual implementation.
[0152] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0153] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.
[0154] It is obvious to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention.
[0155] Therefore, no matter from which point of view, the embodiments should be regarded as illustrative and non-restrictive, and the scope of the present invention is limited by the appended claims rather than the above description, so it is intended that all changes falling within the meaning and scope of the equivalent elements of the claims are included in the present invention. Any attached figure mark in the claims should not be regarded as limiting the claims involved.
[0156] The blockchain referred to in this invention is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm, etc. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the underlying blockchain platform, platform product service layer, and application service layer.
[0157] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the system claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
[0158] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the spirit and scope of the technical solution of the present invention.
Claims
1. A method for training a ranking model based on user retrieval, characterized in that: The method comprises: Acquire a training search term and a search document corresponding to the training search term, perform word segmentation processing on the training search term and all public documents in a preset document set to obtain a search word segmentation and a plurality of public document segmentations, wherein the search document corresponding to the training search term is a matching document or an optimal document corresponding to the training search term; Using a preset first ranking model, the search word and the plurality of public document word segments are encoded and matrix-converted to obtain a search matrix and a plurality of public document matrices; Performing vector inner products of the search matrix and the plurality of public document matrices respectively to obtain a plurality of inner product results, and sorting the plurality of public documents according to the inner product results to obtain a sorted set; Performing text concatenation and vectorization on the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and performing text concatenation and vectorization on the training search terms and the search documents to obtain a concatenated search document vector; Inputting the plurality of concatenated sorting document vectors and the concatenated retrieval document vector into a second sorting model respectively, and obtaining a first output result corresponding to the plurality of concatenated sorting document vectors and a second output result corresponding to the concatenated retrieval document vector; Calculating a plurality of the first output results and the second output results using a preset loss function to obtain a loss value, optimizing the second sorting model according to the loss value, and outputting the optimized second sorting model and the first sorting model as standard sorting models; Among them, the use of a preset first sorting model to encode and matrix-convert the search word and the multiple public document word segments to obtain a search matrix and multiple public document matrices includes: performing vector conversion on the search word and the multiple public document word segments to obtain a first vector set and multiple second vector sets, and position-encoding the vectors in the first vector set and the multiple second vector sets respectively to obtain a first positioning vector set corresponding to the search word and a second positioning vector set corresponding to the multiple public document word segments; performing matrix conversion on the first positioning vector set and the multiple second positioning vector sets, and calculating according to the result of the matrix conversion, the first positioning vector set and the multiple second positioning vector sets to obtain a search matrix and multiple public document matrices; The method of performing matrix conversion on the first positioning vector set and the multiple second positioning vector sets, and obtaining a retrieval matrix and multiple public document matrices based on the result of the matrix conversion, the first positioning vector set and the multiple second positioning vector sets, includes: converting the first positioning vector set and the multiple second positioning vector sets into a first positioning vector matrix and a multiple second positioning vector matrices, and generating a first classification iterative conversion matrix and a multiple second classification iterative conversion matrix based on the dimensions of the first positioning vector matrix and the multiple second positioning vector matrices; obtaining a first original vector correlation matrix corresponding to the first positioning vector set by using a pre-constructed exponential normalization function, the first positioning vector matrix and the first classification iterative conversion matrix for calculation; obtaining a second original vector correlation matrix corresponding to the multiple second positioning vector sets by using the exponential normalization function, the multiple second positioning vector matrices and the multiple second classification iterative conversion matrices for calculation; obtaining a retrieval matrix by using the first original vector correlation matrix and the first positioning vector matrix to adjust the iterative weight factor in the pre-constructed feedforward neural network; and obtaining multiple public document matrices by adjusting the iterative weight factor by using multiple second original vector correlation matrices and the corresponding multiple second positioning vector matrices.
2. The method for training a ranking model based on user retrieval according to claim 1, characterized in that: The word segmentation process is performed on the training search term and all public documents in the preset document set to obtain the search word segmentation and multiple public document word segmentations, including: Using a word segmenter to perform word segmentation processing on the training search term and all public documents in a preset document set, to obtain a first word segmentation corresponding to the training search term and a plurality of second word segmentations corresponding to the public documents; Deleting specific participles of the first participle and the plurality of second participles according to a preset part-of-speech table and a stop word list, to obtain a first target participle corresponding to the training search term and a second target participle corresponding to the plurality of public documents; Punctuation marks in the first target segmentation and multiple second target segmentations are deleted to obtain a search segmentation and multiple public document segmentations.
3. The method for training a ranking model based on user retrieval according to claim 2, characterized in that: The step of deleting specific participles of the first participle and the plurality of second participles according to a preset part-of-speech table and a stop word table to obtain a first target participle corresponding to the training search term and a plurality of second target participles corresponding to the public documents includes: Obtain the part-of-speech tag to be deleted, and extract the corresponding participle in the part-of-speech table according to the part-of-speech tag to be deleted; Extract the corresponding participle in the stop word list; The same segmentations as the corresponding segmentations in the part-of-speech table and the corresponding segmentations in the stop word list are deleted from the first segmentation and the plurality of the second segmentations to obtain the first target segmentation and the plurality of the second target segmentations.
4. The method for training a ranking model based on user retrieval according to claim 1, characterized in that: The performing position encoding on the first vector set and the vectors in the plurality of second vector sets respectively comprises: Extracting vectors from the first vector set and the plurality of second vector sets, and selecting vectors at preset positions from the first vector set and the plurality of second vector sets as coordinate origins; According to the coordinate origin, a position vector of each vector is established, and the position vector is used to perform position encoding on the first vector set and the plurality of second vector sets.
5. The method for training a ranking model based on user retrieval according to any one of claims 1 to 4, characterized in that: The text concatenation and vectorization of the training search terms and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors includes: Selecting a document from the sorted documents as a target document, and dividing the target document into a plurality of text segments; Obtaining an average sentence length of the text segments, and scoring the plurality of text segments according to a preset semantic model and the training search terms; splicing the target document and the training search term according to the average sentence length and the scoring result to obtain a target spliced document; Perform word frequency statistics on the multiple text segments, set weights of the word segments in the multiple text segments according to the results of the word frequency statistics and the scoring results, and generate vector matrices of the multiple text segments according to the weights.
6. A user retrieval-based ranking model training device, used to implement the user retrieval-based ranking model training method according to any one of claims 1 to 5, characterized in that: The device comprises: A word segmentation generation module is used to obtain a training search term and a search document corresponding to the training search term, perform word segmentation processing on the training search term and all public documents in a preset document set, and obtain a search word segmentation and multiple public document word segments; A vector matrix generation module, used for encoding and matrix conversion of the search word and the plurality of public document word segments by using a preset first ranking model to obtain a search matrix and a plurality of public document matrices; A first sorting model calculation module is used to perform vector inner products on the search matrix and the plurality of public document matrices respectively to obtain a plurality of inner product results, and sort the plurality of public documents according to the inner product results to obtain a sorted set; A concatenated retrieval document vector generation module is used to perform text concatenation and vectorization on the training retrieval term and the sorted documents in the sorted set to obtain a plurality of concatenated sorted document vectors, and to perform text concatenation and vectorization on the training retrieval term and the retrieval document to obtain a concatenated retrieval document vector; A second ranking model calculation module, used for inputting the plurality of concatenated ranking document vectors and the concatenated retrieval document vector into a second ranking model respectively, to obtain a first output result corresponding to the plurality of concatenated ranking document vectors and a second output result corresponding to the concatenated retrieval document vector; The standard sorting module generation module is used to use a preset loss function to calculate multiple first output results and second output results to obtain a loss value, and optimize the second sorting model according to the loss value, and output the optimized second sorting model and the first sorting model as standard sorting models.
7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program that can be executed by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute the user retrieval-based ranking model training method as described in any one of claims 1 to 5.
8. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements the user retrieval-based ranking model training method as described in any one of claims 1 to 5.
