Method, system and equipment for processing reordering model, medium and program product
By introducing multi-branch structures and automatic early stop judgment methods into the reordering model, the existing reordering model has been solved, and a more efficient massive data processing is achieved.
Patent Information
- Application Number
- CN202510034399.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-09
- Publication Date
- 2025-04-25
AI Technical Summary
The existing reordering model has slow processing speed and low accuracy, and cannot effectively process massive data.
A reordering model containing multi-branch structure is designed. By freezing the sequence model layer and adding new output layer, the original output layer is first trained based on the high-dimensional feature data set and the low-dimensional feature data set, and then the new output layer is trained based on the trained original output layer to realize automatic early stop judgment and early output.
It greatly improves the processing speed and accuracy of the reordering model, and can process massive data more effectively.
Smart Images

Figure CN119884504A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of model processing, and in particular to a processing method, system, device, medium and program product of a reordering model. Background Art
[0002] In traditional recommendation systems, it is first necessary to find candidate sets that some users are interested in from massive data according to strategy models such as collaborative filtering. This process is called the recall layer, and its purpose is to filter out items that users may be interested in from massive data, which may include some irrelevant items. Then, the relevance of the recalled candidate item set is evaluated, hoping that the model can rank the items that users are interested in to the front and the items that users are not interested in to the back. Appropriate recommended items are selected through thresholds or topk. This process is called the refinement layer, and the model used is called the reranker model.
[0003] With the continuous development and progress of large models, the hallucination problem of large models has also received more and more attention. The Retrieval Augmentation Generation System (RAG) has regained its vitality. It alleviates the hallucination problem by directly injecting the knowledge required to answer questions into the large model prompt, and only uses the reasoning analysis and language organization capabilities of the large model itself. In the RAG system, the retrieval mode of the recommendation system is also adopted. The recall layer mostly uses the similarity comparison of embedding. Because it belongs to a dual-tower model, there is no deep fusion processing of the vector representations of the two, and the accuracy is average; the fine ranking layer uses a re-ranking model, which belongs to a single-tower model. The vector representations of the two are cross-encoded, and the accuracy is higher, but it cannot generate vectors for candidates in advance. Therefore, its speed is slow and time-consuming. It cannot directly sort massive data. Generally speaking, it will select several most relevant document slices and inject them into the large model to answer questions. Summary of the invention
[0004] The technical problem to be solved by the present disclosure is to overcome the defects of slow processing speed and low accuracy of the reordering model in the prior art, and to provide a processing method, system, device, medium and program product of the reordering model.
[0005] The present invention solves the above technical problems through the following technical solutions:
[0006] In a first aspect, the present disclosure provides a processing method for a reordering model, wherein the reordering model includes an original output layer, a sequence model layer, and multiple newly added output layers, each of which includes multiple branch structures, and the processing method includes:
[0007] Acquire a training data set, wherein the training data set includes a high-dimensional feature data set and a low-dimensional feature data set;
[0008] Freezing the sequence model layer and the multiple newly added output layers, and training the original output layer based on the high-dimensional feature data set and the low-dimensional feature data set to obtain a trained original output layer;
[0009] The sequence model layer and the trained original output layer are frozen, and a newly added output layer is trained based on the trained original output layer to obtain a trained newly added output layer.
[0010] Preferably, the processing method further comprises:
[0011] Multiple branch structures of each output layer are trained based on the high-dimensional feature dataset and the low-dimensional feature dataset.
[0012] Preferably, the processing method further comprises:
[0013] The high-dimensional feature data set and the low-dimensional feature data set are analyzed by means of the multiple branch structures.
[0014] Preferably, the processing method further comprises:
[0015] Get the user's historical query questions;
[0016] Performing vector search and keyword search on the user's historical query questions to obtain vector search results and keyword search results;
[0017] Obtaining a search score based on the vector search result and the keyword search result;
[0018] The retrieval scores are ranked, and positive samples and negative samples are obtained from the ranked results.
[0019] Preferably, the processing method further comprises:
[0020] Obtaining a weighted score of a high-dimensional feature data set and a weighted score of a low-dimensional feature data set based on the vector search result and the keyword search result;
[0021] Inputting the user's historical query questions, positive samples, negative samples, weighted scores of the high-dimensional feature data set, and weighted scores of the low-dimensional feature data set into the large model to adjust the relevance scores of the positive samples and negative samples to obtain adjusted relevance scores;
[0022] The adjusted correlation scores are hierarchically divided to obtain a hierarchical division result.
[0023] Preferably, the processing method further comprises:
[0024] The user's query question and candidate documents related to the user's query question are concatenated and input into the re-ranking model to obtain the score ranking result of the candidate documents;
[0025] A candidate document with the largest score is selected from the score ranking results as the target candidate document for the user's query question.
[0026] A second aspect of the present disclosure provides a processing system for a reordering model, wherein the reordering model includes an original output layer, a sequence model layer, and multiple newly added output layers, each of which includes multiple branch structures, and the processing system includes:
[0027] A first acquisition module is used to acquire a training data set, where the training data set includes a high-dimensional feature data set and a low-dimensional feature data set;
[0028] A first training module, used for freezing the sequence model layer and the multiple newly added output layers, and training the original output layer based on the high-dimensional feature data set and the low-dimensional feature data set to obtain the trained original output layer;
[0029] The second training module is used to freeze the sequence model layer and the trained original output layer, and train the newly added output layer based on the trained original output layer to obtain the trained newly added output layer.
[0030] Preferably, the processing system further comprises:
[0031] The third training module is used to train multiple branch structures of each output layer based on the high-dimensional feature data set and the low-dimensional feature data set.
[0032] Preferably, the processing system further comprises:
[0033] An analysis module is used to analyze the high-dimensional feature data set and the low-dimensional feature data set through the multiple branch structures.
[0034] Preferably, the processing system further comprises:
[0035] The second acquisition module is used to obtain the user's historical query questions;
[0036] A search module, used to perform vector search and keyword search on the user's historical query questions to obtain vector search results and keyword search results;
[0037] A third acquisition module, configured to acquire a search score based on the vector search result and the keyword search result;
[0038] The first sorting module is used to sort the search scores and obtain positive samples and negative samples from the sorting results.
[0039] Preferably, the processing system further comprises:
[0040] A fourth acquisition module, used to acquire a weighted score of a high-dimensional feature data set and a weighted score of a low-dimensional feature data set based on the vector search result and the keyword search result;
[0041] An adjustment module, used for inputting the user's historical query questions, positive samples, negative samples, weighted scores of the high-dimensional feature data set and weighted scores of the low-dimensional feature data set into the large model to adjust the relevance scores of the positive samples and negative samples to obtain adjusted relevance scores;
[0042] The hierarchical division module is used to hierarchically divide the adjusted correlation scores to obtain hierarchical division results.
[0043] Preferably, the processing system further comprises:
[0044] A fifth acquisition module is used to splice the user's query question and the candidate documents related to the user's query question and input them into the re-ranking model to obtain the score ranking result of the candidate documents;
[0045] A selection module is used to select a candidate document with the largest score from the score ranking results as a target candidate document for the user's query question.
[0046] A third aspect of the present disclosure provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and used to run on the processor, wherein the processor implements the processing method of the reordering model described in the first aspect when executing the computer program.
[0047] A fourth aspect of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the processing method of the reordering model described in the first aspect is implemented.
[0048] A fifth aspect of the present disclosure provides a computer program product, including a computer program, which, when executed by a processor, implements the processing method of the reordering model as described in the first aspect.
[0049] On the basis of being in accordance with the common sense in the art, the above-mentioned preferred conditions can be arbitrarily combined to obtain the preferred embodiments of the present disclosure.
[0050] The positive and progressive effects of this disclosure are:
[0051] The present invention constructs a reordering model with a multi-branch structure. The original output layer is first trained based on a high-dimensional feature data set and a low-dimensional feature data set, and then a new output layer is trained based on the trained original output layer. The trained new output layer can automatically determine early stopping, which greatly improves the processing speed and accuracy of the reordering model. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] Figure 1 A schematic diagram of the structure of the reordering model provided for Embodiments 1 and 2 of the present disclosure.
[0053] Figure 2 A flowchart of the processing method of the reordering model provided in Example 1 of the present disclosure.
[0054] Figure 3 A module diagram of a processing system for a reordering model provided in Embodiment 2 of the present disclosure.
[0055] Figure 4 This is a schematic diagram of the structure of an electronic device for implementing the processing method of the reordering model according to Embodiment 3 of the present disclosure. DETAILED DESCRIPTION
[0056] The present disclosure is further described below by way of examples, but the present disclosure is not limited to the scope of the examples.
[0057] Prefixes such as "first" and "second" are used in the embodiments of the present disclosure only to distinguish different description objects, and have no limiting effect on the position, order, priority, quantity or content of the described objects. The use of prefixes such as ordinal numbers to distinguish description objects in the embodiments of the present disclosure does not constitute a limitation on the described objects. For the statement of the described objects, please refer to the description in the context of the embodiments, and no unnecessary limitation should be constituted due to the use of such prefixes. In addition, in the description of the present embodiment, unless otherwise specified, the meaning of "plurality" is two or more.
[0058] In the embodiments of the present disclosure, the collection, storage, use, processing, transmission, provision and disclosure of user personal information involved are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0059] Example 1
[0060] Figure 1 A flowchart of a processing method for a reordering model provided in Embodiment 1 of the present disclosure is shown in FIG. Figure 1 As shown in , the reordering model includes the original output layer, the sequence model (transformer) layer and multiple new output layers, each of which includes multiple branch structures, such as Figure 1 Taking the two-branch structure as an example, the two branch structures are used to analyze and understand high-dimensional feature data sets and low-dimensional feature data sets of different dimensions, such as Figure 2 As shown, the processing method includes:
[0061] S1. Obtain a training data set, where the training data set includes a high-dimensional feature data set and a low-dimensional feature data set;
[0062] In this embodiment, data sets are constructed for high-dimensional features and low-dimensional features, i.e., similar semantics and similar keywords, and multiple strategies are used for score evaluation. The similarity distribution of the training data set is statistically analyzed and divided into 16 / 32 correlation score levels in unequal proportions, so that the number of samples in each interval is roughly close;
[0063] Specifically, since the reranking model adopts different branch structures for high-dimensional features and low-dimensional features, two data sets need to be constructed separately (because the two-dimensional features cannot be completely separated and do not need to be separated very accurately). The data set is mainly constructed with domain knowledge in the business and open source data sets in a 1:1 ratio. Two annotations need to be made for each piece of data, one is the relevance score, and the other is the positive and negative samples.
[0064] S2, freezing the sequence model layer and multiple newly added output layers, and training the original output layer based on the high-dimensional feature data set and the low-dimensional feature data set to obtain the trained original output layer;
[0065] In this embodiment, in the first stage of training: since the parameters of the output layer are randomly initialized, it is likely that the model converges slowly or does not converge at all in the full parameter fine-tuning training, the parameters of the transformer (sequence model) layer of the backbone and the newly added output layer in the middle are first frozen, and then the original output layer is trained using the high-dimensional feature data set and the low-dimensional feature data set respectively;
[0066] Specifically, the output layer parameters are initialized, the final output layer is trained, the main transformer network structure and the branch output layer added in the middle layer are frozen, the high-dimensional branches and low-dimensional branches are frozen respectively, and the high-dimensional feature and low-dimensional feature data sets are trained as the initialization parameters of the output layer. The full parameters of the mixed data set are fine-tuned or only the final output layer is trained.
[0067] S3, freezing the sequence model layer and the original output layer after training, and training the newly added output layer based on the original output layer after training to obtain the newly added output layer after training.
[0068] In this embodiment, the second stage of training: freezing the trained network structure (i.e. freezing the sequence model layer and the original output layer after training), using the final output layer as the teacher network, and using the self-distillation method to train the branch output layer of the intermediate layer;
[0069] Specifically, multiple output layers (for example, two output layers) are added in the middle of training, and the knowledge distillation method is mainly used. The final output layer is used as the teacher network. The sequences that need to be compared include the outputs of the two branches and the category probability distribution of the interval segmentation, a total of three sequences.
[0070] It should be noted that when training a branch, the parameters of the other branch should be frozen (the purpose of freezing is to ensure that the parameters remain unchanged). This process can be trained quickly because there are fewer trainable parameters, and the trained weight values are used as the initialization parameters for fine-tuning all parameters; the two data sets are fully mixed and shuffled, and the entire network is trained. If the number of network layers used is deep, only several transformer layers connected to the output layer can be trained.
[0071] This embodiment constructs a reordering model with a multi-branch structure. The original output layer is first trained based on a high-dimensional feature data set and a low-dimensional feature data set, and then a new output layer is trained based on the trained original output layer. The trained new output layer can automatically determine early stopping, which greatly improves the processing speed and accuracy of the reordering model.
[0072] In an optional embodiment, the processing method further includes:
[0073] Multiple branch structures of each output layer are trained based on high-dimensional feature datasets and low-dimensional feature datasets.
[0074] In an optional embodiment, the processing method further includes:
[0075] Analyze high-dimensional feature datasets and low-dimensional feature datasets through multiple branch structures.
[0076] In this embodiment, each branch structure is used to process different text features, which are respectively the understanding of a high-dimensional feature data set and a low-dimensional feature data set.
[0077] In an optional embodiment, the processing method further includes:
[0078] Get the user's historical query questions;
[0079] Perform vector search and keyword search on the user's historical query questions to obtain vector search results and keyword search results;
[0080] Obtain search scores based on vector search results and keyword search results;
[0081] The retrieval scores are ranked and positive and negative samples are obtained from the ranked results.
[0082] In this embodiment, the user's historical query questions are used to perform vector search and keyword search (bm25 score) in different knowledge bases, and the top 20 highest ranked and the 20 ranked 40-60 are selected to ensure that they contain positive samples and negative samples with similar proportions.
[0083] In an optional embodiment, the processing method further includes:
[0084] Obtaining weighted scores of high-dimensional feature data sets and weighted scores of low-dimensional feature data sets based on vector retrieval results and keyword retrieval results;
[0085] In this embodiment, for the vector retrieval results, a re-ranking model is used to calculate the cosine similarity and the re-ranking score to obtain a weighted score of the high-dimensional feature data set;
[0086] For keyword search results, since they will definitely contain the same fragments or phrases as those in the question, you can use jaccard coefficient, lcs, edit distance and other metrics to calculate the similarity score, and weight it with the bm25 score to get the weighted score of the low-dimensional feature data set;
[0087] The user's historical query questions, positive samples, negative samples, weighted scores of high-dimensional feature data sets, and weighted scores of low-dimensional feature data sets are all input into the large model to adjust the relevance scores of positive samples and negative samples to obtain adjusted relevance scores;
[0088] In this embodiment, a large model is used to perform the final score adjustment and positive and negative sample judgment. The user's historical query questions, positive and negative samples, weighted scores of high-dimensional feature data sets, and weighted scores of low-dimensional feature data sets are simultaneously input into the large model prompt and sorted according to the existing scores. The large model adjusts the correlation scores of positive and negative samples (for example, between 0 and 1), and performs correlation judgment on positive and negative samples.
[0089] The adjusted relevance scores are hierarchically divided to obtain hierarchical division results.
[0090] In this embodiment, the correlation score is divided into levels: the data distribution of the correlation score after statistical adjustment is divided into equal samples, that is, solving an optimization problem to ensure that the number of samples in each interval is close and the variance of the number of samples in different intervals is minimized; using a heuristic algorithm-genetic algorithm to solve, the split point is defined as a node, and the number of samples in each interval is defined as the weight value of the edge, that is, solving a path containing k-1 nodes, so that for all problems, the average variance of the edge weight value is minimized. According to practical experience, it can be selected to be divided into 16 or 32 intervals.
[0091] In an optional embodiment, the processing method further includes:
[0092] The user's query question and candidate documents related to the user's query question are concatenated and input into the re-ranking model to obtain the score ranking result of the candidate documents;
[0093] Select the candidate document with the largest score from the score ranking results as the target candidate document for the user's query question.
[0094] In this embodiment, the user's query question and the candidate documents related to the user's query question are spliced and input into the re-ranking model to obtain the score ranking result of the candidate documents. When passing the first output layer, since the maximum confidence of the classification is 0.37, which is not greater than the set threshold value of 0.65, it is not output and reasoning continues; when reaching the second output layer, the probability distribution is calculated, and the confidence is 0.71, which is greater than 0.65, and the output of the two-classification layer is continued to be calculated. Category 0 represents the probability of irrelevant, and category 1 represents the probability of relevant, and the probability of category 1 is used as the final output score.
[0095] The candidate documents are cut into pieces and further divided into k clauses according to the whole sentence. The reranking model calculates the relevance scores of the candidate documents and the clauses respectively and takes the maximum value. This will increase the time loss of the tokens of the k query questions, which is less time-consuming and can improve the accuracy of the score estimation to a certain extent.
[0096] In the specific implementation process, Figure 1 As shown in the figure, two branch output layers are added in the middle of the network layer to output the results in advance. When the query question is directly related to the candidate document (easy to understand), it can be directly output in the shallow layer. The judgment condition can be whether the confidence exceeds the threshold. In this way, the reasoning can be ended in advance through adaptive judgment, which speeds up the reasoning speed. Multiple branches are added to the output layer, each branch is used to process different text features, namely, the understanding of high-dimensional features and low-dimensional features. A gating unit is added to perform weighted summation on the output results of the two branches.
[0097] In order to improve the reasoning speed of the reordering model, we try to introduce an early stopping strategy into the reordering model structure, mainly by adding an output layer after the middle transformer layer, such as Figure 1 As shown in the figure, two output layers are connected to the middle layer, each of which has the same structure as the final output layer, but the parameters are not shared. When encountering a specific output layer, it is necessary to determine whether the output condition is met. If it is met, the model is directly exited without continuing the subsequent reasoning. Otherwise, it continues until the output condition is met or the final output layer is reached.
[0098] In the process of using the reranking model, table-based retrieval usually has weak semantic information and mainly relies on keywords to locate row and column information. The reranker model may rank the document containing the answer to the back. In order to process semantic information of different dimensions separately in the reranking model, the present disclosure proposes a branching structure of features, which mainly includes two multi-layer neural networks with the same structure (including only fully connected layers), a gated unit structure, a relevance level output classification layer, and a positive and negative correlation output layer.
[0099] Furthermore, the input text is query+candidate document, which is input into the high-dimensional feature and low-dimensional feature branches respectively after the transformer layer. Then, the output vectors of the two branches are concatenated / point-by-point added and input into the gating unit. The gating unit outputs a weight value between 0 and 1, representing the weighted value a of the output result of the high-dimensional (semantic) feature branch, and the weighted value of the low-dimensional (keyword) branch is 1-a. After the weighted summation of the two vectors, a fully connected layer and a softmax layer are passed to output the probability distribution of the relevance level classification, and it is judged whether the confidence of the current prediction interval exceeds the threshold. If it exceeds, the final interval segmentation result and prediction score are directly output, otherwise, the reasoning continues. It is worth noting that the two branches use weighted summation rather than 0 / 1 trade-off, mainly because high-dimensional features and low-dimensional features cannot be completely separated, and a document must be related to the query problem in two aspects.
[0100] Furthermore, there are two ways to deal with manually defined rules. Let's take the label priority rule as an example. Assume that the knowledge base contains 4 types of labels, and their importance is manually defined as [0.4, 0.3, 0.2, 0.1]. When there are two documents with similar scores, label priority will come into play: (1) Treat the artificial rule as a special feature and add a rule branch, which is exactly the same as the high-dimensional feature and low-dimensional feature branch structure. In the input layer, a 4x256 feature vector is randomly initialized as the category vector and weighted according to the importance score. At this time, when constructing the data set, the large model needs to consider the weight relationship of the label when generating the score. (2) Do not change the network structure, divide the input into two parts, the first is query+candidatedocument, and the second is query+label. After the two scores are weighted, they can be directly multiplied by the weight. The second reasoning calculation score is to ensure normal output when some rules are not applicable.
[0101] Furthermore, the loss functions in the training process are the cross entropy loss function (Lcoss) and the mean square error loss function MSE, which correspond to the output of the interval segmentation category and the score value of the binary classification layer output respectively; the expressions of the cross entropy loss function (Lcoss) and the mean square error loss function MSE are shown in formula (1) and formula (2):
[0102] (1)
[0103] Among them, Lcoss represents the cross entropy loss function, N represents the number of training data, K represents the number of hierarchical divisions, and y ik Indicates that the i-th sample is in the k-th level, log ikrepresents the score of the i-th sample in the k-th level, where i and k are both integers;
[0104] (2)
[0105] Among them, L2 represents the mean square error loss function, y i Represents the similarity scores between the query question and the positive and negative samples, i Represents the output score of the reranking model.
[0106] Furthermore, the above loss function needs to be able to measure the similarity of the distribution of two sequences, using KL divergence to measure. Assuming that P is the output sequence of the teacher network and Q is the output of the student network, the calculation formula is shown in formula (3):
[0107] (3)
[0108] Among them, D KL (P ) represents the KL divergence, P(i) represents the i-th vector value in the output sequence of the teacher network, and Q(i) represents the i-th vector value in the output sequence of the student network.
[0109] This embodiment constructs a re-ranking model structure with a multi-branch structure and a multi-output layer. The multi-branch structure can be used to analyze and understand features of different dimensions, which refer to high-dimensional features that are biased towards semantics and low-dimensional features that are biased towards specific keywords. The multi-output layer can automatically determine early stopping and output prediction scores in advance, which can greatly improve the accuracy of knowledge retrieval and the reasoning speed of the re-ranking model.
[0110] Example 2
[0111] Corresponding to the aforementioned embodiment of a method for processing a reordering model, the present disclosure also provides an embodiment of a system for processing a reordering model.
[0112] Figure 3 A schematic diagram of a module of a processing system for a reordering model provided in Embodiment 2 of the present disclosure, such as Figure 1 As shown in , the reordering model includes the original output layer, the sequence model (transformer) layer and multiple new output layers, each of which includes multiple branch structures, such as Figure 1 Taking the two-branch structure as an example, the two branch structures are used to analyze and understand high-dimensional feature data sets and low-dimensional feature data sets of different dimensions, such as Figure 3 As shown, the processing system includes: a first acquisition module 21, a first training module 22, and a second training module 23;
[0113] A first acquisition module 21 is used to acquire a training data set, where the training data set includes a high-dimensional feature data set and a low-dimensional feature data set;
[0114] In this embodiment, data sets are constructed for high-dimensional features and low-dimensional features, i.e., similar semantics and similar keywords, and multiple strategies are used for score evaluation. The similarity distribution of the training data set is statistically analyzed and divided into 16 / 32 correlation score levels in unequal proportions, so that the number of samples in each interval is roughly close;
[0115] Specifically, since the reranking model adopts different branch structures for high-dimensional features and low-dimensional features, two data sets need to be constructed separately (because the two-dimensional features cannot be completely separated and do not need to be separated very accurately). The data set is mainly constructed with domain knowledge in the business and open source data sets in a 1:1 ratio. Two annotations need to be made for each piece of data, one is the relevance score, and the other is the positive and negative samples.
[0116] A first training module 22 is used to freeze the sequence model layer and the multiple newly added output layers, and train the original output layer based on the high-dimensional feature data set and the low-dimensional feature data set to obtain the trained original output layer;
[0117] In this embodiment, in the first stage of training: since the parameters of the output layer are randomly initialized, it is likely that the model converges slowly or does not converge at all in the full parameter fine-tuning training, the parameters of the transformer (sequence model) layer of the backbone and the newly added output layer in the middle are first frozen, and then the original output layer is trained using the high-dimensional feature data set and the low-dimensional feature data set respectively;
[0118] Specifically, the output layer parameters are initialized, the final output layer is trained, the main transformer network structure and the branch output layer added in the middle layer are frozen, the high-dimensional branches and low-dimensional branches are frozen respectively, and the high-dimensional feature and low-dimensional feature data sets are trained as the initialization parameters of the output layer. The full parameters of the mixed data set are fine-tuned or only the final output layer is trained.
[0119] The second training module 23 is used to freeze the sequence model layer and the trained original output layer, and train the newly added output layer based on the trained original output layer to obtain the trained newly added output layer.
[0120] In this embodiment, the second stage of training: freezing the trained network structure (i.e. freezing the sequence model layer and the original output layer after training), using the final output layer as the teacher network, and using the self-distillation method to train the branch output layer of the intermediate layer;
[0121] Specifically, multiple output layers (for example, two output layers) are added in the middle of training, and the knowledge distillation method is mainly used. The final output layer is used as the teacher network. The sequences that need to be compared include the outputs of the two branches and the category probability distribution of the interval segmentation, a total of three sequences.
[0122] It should be noted that when training a branch, the parameters of the other branch should be frozen (the purpose of freezing is to ensure that the parameters remain unchanged). This process can be trained quickly because there are fewer trainable parameters, and the trained weight values are used as the initialization parameters for fine-tuning all parameters; the two data sets are fully mixed and shuffled, and the entire network is trained. If the number of network layers used is deep, only several transformer layers connected to the output layer can be trained.
[0123] This embodiment constructs a reordering model with a multi-branch structure. The original output layer is first trained based on a high-dimensional feature data set and a low-dimensional feature data set, and then a new output layer is trained based on the trained original output layer. The trained new output layer can automatically determine early stopping, which greatly improves the processing speed and accuracy of the reordering model.
[0124] In an optional embodiment, the processing system further includes:
[0125] The third training module is used to train multiple branch structures of each output layer based on the high-dimensional feature data set and the low-dimensional feature data set.
[0126] In an optional embodiment, the processing system further includes:
[0127] The analysis module is used to analyze high-dimensional feature data sets and low-dimensional feature data sets through multiple branch structures.
[0128] In this embodiment, each branch structure is used to process different text features, which are respectively the understanding of a high-dimensional feature data set and a low-dimensional feature data set.
[0129] In an optional embodiment, the processing system further includes:
[0130] The second acquisition module is used to obtain the user's historical query questions;
[0131] A retrieval module is used to perform vector retrieval and keyword retrieval on the user's historical query questions to obtain vector retrieval results and keyword retrieval results;
[0132] A third acquisition module, used to acquire a search score based on the vector search result and the keyword search result;
[0133] The first sorting module is used to sort the retrieval scores and obtain positive samples and negative samples from the sorting results.
[0134] In this embodiment, the user's historical query questions are used to perform vector search and keyword search (bm25 score) in different knowledge bases, and the top 20 highest ranked and the 20 ranked 40-60 are selected to ensure that they contain positive samples and negative samples with similar proportions.
[0135] In an optional embodiment, the processing system further includes:
[0136] A fourth acquisition module, used to acquire a weighted score of the high-dimensional feature data set and a weighted score of the low-dimensional feature data set based on the vector search result and the keyword search result;
[0137] In this embodiment, for the vector retrieval results, a re-ranking model is used to calculate the cosine similarity and the re-ranking score to obtain a weighted score of the high-dimensional feature data set;
[0138] For keyword search results, since they will definitely contain the same fragments or phrases as those in the question, you can use jaccard coefficient, lcs, edit distance and other metrics to calculate the similarity score, and weight it with the bm25 score to get the weighted score of the low-dimensional feature data set;
[0139] An adjustment module, used to input the user's historical query questions, positive samples, negative samples, weighted scores of high-dimensional feature data sets, and weighted scores of low-dimensional feature data sets into the large model to adjust the relevance scores of positive samples and negative samples to obtain adjusted relevance scores;
[0140] In this embodiment, a large model is used to perform the final score adjustment and positive and negative sample judgment. The user's historical query questions, positive and negative samples, weighted scores of high-dimensional feature data sets, and weighted scores of low-dimensional feature data sets are simultaneously input into the large model prompt and sorted according to the existing scores. The large model adjusts the correlation scores of positive and negative samples (for example, between 0 and 1), and performs correlation judgment on positive and negative samples.
[0141] The hierarchical division module is used to perform hierarchical division on the adjusted relevance scores to obtain hierarchical division results.
[0142] In this embodiment, the correlation score is divided into levels: the data distribution of the correlation score after statistical adjustment is divided into equal samples, that is, solving an optimization problem to ensure that the number of samples in each interval is close and the variance of the number of samples in different intervals is minimized; using a heuristic algorithm-genetic algorithm to solve, the split point is defined as a node, and the number of samples in each interval is defined as the weight value of the edge, that is, solving a path containing k-1 nodes, so that for all problems, the average variance of the edge weight value is minimized. According to practical experience, it can be selected to be divided into 16 or 32 intervals.
[0143] In an optional embodiment, the processing system further includes:
[0144] A fifth acquisition module is used to splice the user's query question and the candidate documents related to the user's query question and input them into the re-ranking model to obtain the score ranking result of the candidate documents;
[0145] The selection module is used to select the candidate document with the largest score from the score ranking results as the target candidate document for the user's query question.
[0146] In this embodiment, the user's query question and the candidate documents related to the user's query question are spliced and input into the re-ranking model to obtain the score ranking result of the candidate documents. When passing the first output layer, since the maximum confidence of the classification is 0.37, which is not greater than the set threshold value of 0.65, it is not output and reasoning continues; when reaching the second output layer, the probability distribution is calculated, and the confidence is 0.71, which is greater than 0.65, and the output of the two-classification layer is continued to be calculated. Category 0 represents the probability of irrelevant, and category 1 represents the probability of relevant, and the probability of category 1 is used as the final output score.
[0147] The candidate documents are cut into pieces and further divided into k clauses according to the whole sentence. The reranking model calculates the relevance scores of the candidate documents and the clauses respectively and takes the maximum value. This will increase the time loss of the tokens of the k query questions, which is less time-consuming and can improve the accuracy of the score estimation to a certain extent.
[0148] In the specific implementation process, Figure 1 As shown in the figure, two branch output layers are added in the middle of the network layer to output the results in advance. When the query question is directly related to the candidate document (easy to understand), it can be directly output in the shallow layer. The judgment condition can be whether the confidence exceeds the threshold. In this way, the reasoning can be ended in advance through adaptive judgment, which speeds up the reasoning speed. Multiple branches are added to the output layer, each branch is used to process different text features, namely, the understanding of high-dimensional features and low-dimensional features. A gating unit is added to perform weighted summation on the output results of the two branches.
[0149] In order to improve the reasoning speed of the reordering model, we try to introduce an early stopping strategy into the reordering model structure, mainly by adding an output layer after the middle transformer layer, such as Figure 1 As shown in the figure, two output layers are connected to the middle layer, each of which has the same structure as the final output layer, but the parameters are not shared. When encountering a specific output layer, it is necessary to determine whether the output condition is met. If it is met, the model is directly exited without continuing the subsequent reasoning. Otherwise, it continues until the output condition is met or the final output layer is reached.
[0150] In the process of using the reranking model, table-based retrieval usually has weak semantic information and mainly relies on keywords to locate row and column information. The reranker model may rank the document containing the answer to the back. In order to process semantic information of different dimensions separately in the reranking model, the present disclosure proposes a branching structure of features, which mainly includes two multi-layer neural networks with the same structure (including only fully connected layers), a gated unit structure, a relevance level output classification layer, and a positive and negative correlation output layer.
[0151] Furthermore, the input text is query+candidate document, which is input into the high-dimensional feature and low-dimensional feature branches respectively after the transformer layer. Then, the output vectors of the two branches are concatenated / point-by-point added and input into the gating unit. The gating unit outputs a weight value between 0 and 1, representing the weighted value a of the output result of the high-dimensional (semantic) feature branch, and the weighted value of the low-dimensional (keyword) branch is 1-a. After the weighted summation of the two vectors, a fully connected layer and a softmax layer are passed to output the probability distribution of the relevance level classification, and it is judged whether the confidence of the current prediction interval exceeds the threshold. If it exceeds, the final interval segmentation result and prediction score are directly output, otherwise, the reasoning continues. It is worth noting that the two branches use weighted summation rather than 0 / 1 trade-off, mainly because high-dimensional features and low-dimensional features cannot be completely separated, and a document must be related to the query problem in two aspects.
[0152] Furthermore, there are two ways to deal with manually defined rules. Let's take the label priority rule as an example. Assume that the knowledge base contains 4 types of labels, and their importance is manually defined as [0.4, 0.3, 0.2, 0.1]. When there are two documents with similar scores, label priority will come into play: (1) Treat the artificial rule as a special feature and add a rule branch, which is exactly the same as the high-dimensional feature and low-dimensional feature branch structure. In the input layer, a 4x256 feature vector is randomly initialized as the category vector and weighted according to the importance score. At this time, when constructing the data set, the large model needs to consider the weight relationship of the label when generating the score. (2) Do not change the network structure, divide the input into two parts, the first is query+candidatedocument, and the second is query+label. After the two scores are weighted, they can be directly multiplied by the weight. The second reasoning calculation score is to ensure normal output when some rules are not applicable.
[0153] Furthermore, the loss functions in the training process are the cross entropy loss function (Lcoss) and the mean square error loss function MSE, which correspond to the output of the interval segmentation category and the score value of the binary classification layer output respectively; the expressions of the cross entropy loss function (Lcoss) and the mean square error loss function MSE are shown in formula (1) and formula (2).
[0154] Furthermore, the above loss function needs to be able to measure the similarity of the distribution of two sequences, using KL divergence to measure. Assuming that P is the output sequence of the teacher network and Q is the output of the student network, the calculation formula is shown in formula (3).
[0155] This embodiment constructs a re-ranking model structure with a multi-branch structure and a multi-output layer. The multi-branch structure can be used to analyze and understand features of different dimensions, which refer to high-dimensional features that are biased towards semantics and low-dimensional features that are biased towards specific keywords. The multi-output layer can automatically determine early stopping and output prediction scores in advance, which can greatly improve the accuracy of knowledge retrieval and the reasoning speed of the re-ranking model.
[0156] As for the system embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The system embodiment described above is only illustrative, wherein the units described as separate components may or may not be physically separated, and the components as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the disclosed solution.
[0157] Example 3
[0158] Figure 4 This is a structural diagram of an electronic device shown in Embodiment 3 of the present disclosure, wherein the electronic device includes a memory, a processor, and a computer program stored in the memory and used to run on the processor, and when the processor executes the computer program, the processing method of the reordering model described in any of the above embodiments is implemented. Figure 4 The electronic device 90 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.
[0159] like Figure 4 As shown, the electronic device 90 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 90 may include, but are not limited to: at least one processor 91, at least one memory 92, and a bus 93 connecting different system components (including the memory 92 and the processor 91).
[0160] The bus 93 includes a data bus, an address bus, and a control bus.
[0161] The memory 92 may include a volatile memory, such as a random access memory (RAM) 921 and / or a cache memory 922 , and may further include a read only memory (ROM) 923 .
[0162] The memory 92 may also include a program tool 925 (or utility) having a set (at least one) of program modules 924, such program modules 924 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0163] The processor 91 executes various functional applications and data processing by running the computer program stored in the memory 92, such as the processing method of the reordering model provided in any of the above embodiments.
[0164] The electronic device 90 may also communicate with one or more external devices 94 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 95. Furthermore, the electronic device 90 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 96. Figure 4 As shown, the network adapter 96 communicates with other modules of the electronic device 90 via the bus 93. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 90, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
[0165] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.
[0166] Example 4
[0167] Embodiment 4 of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for processing the reordering model provided in any of the above embodiments is implemented.
[0168] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.
[0169] Example 5
[0170] Embodiment 5 of the present disclosure further provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned methods for processing the reordering model.
[0171] Among them, the program code for executing the computer program product of the present disclosure can be written in any combination of one or more programming languages, and the program code can be executed completely on the user device, partially on the user device, as an independent software package, partially on the user device and partially on a remote device, or completely on the remote device.
[0172] Although the specific embodiments of the present disclosure are described above, those skilled in the art should understand that this is only an example, and the protection scope of the present disclosure is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present disclosure, but these changes and modifications all fall within the protection scope of the present disclosure.
Claims
1. A method for processing a reordering model, characterized in that: The reordering model includes an original output layer, a sequence model layer and multiple newly added output layers, each of which includes multiple branch structures, and the processing method includes: Acquire a training data set, wherein the training data set includes a high-dimensional feature data set and a low-dimensional feature data set; Freezing the sequence model layer and the multiple newly added output layers, and training the original output layer based on the high-dimensional feature data set and the low-dimensional feature data set to obtain a trained original output layer; The sequence model layer and the trained original output layer are frozen, and a newly added output layer is trained based on the trained original output layer to obtain a trained newly added output layer.
2. The method for processing a reordering model according to claim 1, characterized in that: The processing method also includes: Multiple branch structures of each output layer are trained based on the high-dimensional feature dataset and the low-dimensional feature dataset.
3. The method for processing a reordering model according to claim 1, characterized in that: The processing method also includes: The high-dimensional feature data set and the low-dimensional feature data set are analyzed by means of the multiple branch structures.
4. The method for processing a reordering model according to claim 1, wherein: The processing method also includes: Get the user's historical query questions; Performing vector search and keyword search on the user's historical query questions to obtain vector search results and keyword search results; Obtaining a search score based on the vector search result and the keyword search result; The retrieval scores are ranked, and positive samples and negative samples are obtained from the ranked results.
5. The method for processing the reordering model according to claim 4, characterized in that: The processing method also includes: Obtaining a weighted score of a high-dimensional feature data set and a weighted score of a low-dimensional feature data set based on the vector search result and the keyword search result; Inputting the user's historical query questions, positive samples, negative samples, weighted scores of the high-dimensional feature data set, and weighted scores of the low-dimensional feature data set into the large model to adjust the relevance scores of the positive samples and negative samples to obtain adjusted relevance scores; The adjusted correlation scores are hierarchically divided to obtain a hierarchical division result.
6. The method for processing a reordering model according to any one of claims 1 to 5, characterized in that: The processing method also includes: The user's query question and candidate documents related to the user's query question are concatenated and input into the re-ranking model to obtain the score ranking result of the candidate documents; A candidate document with the largest score is selected from the score ranking results as the target candidate document for the user's query question.
7. A processing system for a reordering model, characterized in that: The reordering model includes an original output layer, a sequence model layer and a plurality of newly added output layers, each of which includes a plurality of branch structures, and the processing system includes: A first acquisition module is used to acquire a training data set, where the training data set includes a high-dimensional feature data set and a low-dimensional feature data set; A first training module, used for freezing the sequence model layer and the multiple newly added output layers, and training the original output layer based on the high-dimensional feature data set and the low-dimensional feature data set to obtain the trained original output layer; The second training module is used to freeze the sequence model layer and the trained original output layer, and train the newly added output layer based on the trained original output layer to obtain the trained newly added output layer.
8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and used to run on the processor, characterized in that: When the processor executes the computer program, the method for processing the reordering model according to any one of claims 1 to 6 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the processing method of the reordering model according to any one of claims 1 to 6 is implemented.
10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the processing method of the reordering model according to any one of claims 1 to 6 is implemented.