A view ranking method, device, computer equipment and storage medium
By using the pairwise opinion comparison model and the global ranking model, combined with the probability distribution parameters of the feature extraction and symmetric difference prediction modules, the problem of insufficient generalization ability of traditional opinion ranking methods is solved, and a more efficient opinion ranking is achieved.
Patent Information
- Application Number
- CN202411818745.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2044-12-10
AI Technical Summary
Traditional viewpoint ranking methods have poor generalization capabilities, resulting in poor ranking results.
The opinion comparison model is used to combine paired opinions. The feature extraction module and the symmetric difference prediction module are used, combined with the variable parameters of the set probability distribution, and the opinion strength parameters are determined by the global ranking model for sorting.
The generalization ability and performance of opinion ranking have been improved, which can better adapt to different data characteristics and situations and provide more accurate opinion ranking results.
Smart Images

Figure CN119760228B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, apparatus, computer device and storage medium for sorting opinions. Background Art
[0002] In technical scenarios such as content recommendation, information retrieval, data cleaning and filtering, and opinion aggregation, finding the highest-quality data from a vast amount of opinion, content, or information is a common challenge. Traditional approaches sometimes determine the quality of data output based on the reliability of the data publisher, while others instruct neural network models to learn and assess quality based on historical data annotations. However, opinion ranking methods in these traditional approaches often suffer from poor generalization, resulting in poor ranking results. Summary of the Invention
[0003] The purpose of this application is to solve at least one of the above-mentioned technical deficiencies, especially the problem of poor sorting effect caused by weak generalization ability in traditional technologies.
[0004] In a first aspect, the present application provides a method for ranking viewpoints, comprising:
[0005] Combine the target opinions in the opinion set to be sorted in pairs to obtain multiple groups of paired opinions;
[0006] Input each pair of opinions into a pairwise opinion comparison model to obtain the relative ranking of each pair of opinions; the opinion comparison model includes a feature extraction module and a symmetric difference prediction module, and the model parameters in the symmetric difference prediction module include variables that conform to a set probability distribution;
[0007] Input each relative ranking into the global ranking model to obtain the strength parameter of each target viewpoint;
[0008] Target viewpoints are ranked in descending order according to the strength parameter.
[0009] In one embodiment, the feature extraction module includes an embedding layer, a multi-head attention unit, and a flattening layer; each pair of opinions is input into a pairwise opinion comparison model to obtain a relative ranking of each pair of opinions, including:
[0010] The two target views in the paired viewpoints are input into the feature extraction module respectively to obtain their corresponding feature vectors. The embedding layer is used to convert the input target viewpoint into an embedded feature of the target dimension, the multi-head attention unit is used to convert the embedded feature into an attention score, and the flattening layer is used to convert the attention score into a feature vector.
[0011] A pair of feature vectors is input into the symmetric difference prediction module to obtain the relative ranking.
[0012] In one of the embodiments, the multi-head attention unit includes a plurality of multi-head attention layers, a multi-head attention layer directly connected with the embedding layer processes the embedding features using the multi-head attention mechanism and outputs to a next multi-head attention layer, and other multi-head attention layers process outputs of a previous multi-head attention layer using the multi-head attention mechanism and output to a next multi-head attention layer.
[0013] In one of the embodiments, a residual connection is arranged between the input and the output of each multi-head attention layer.
[0014] In one of the embodiments, the symmetric difference prediction module includes a difference construction unit, a prediction unit and a comparison unit, a pair of feature vectors includes a first feature vector and a second feature vector, the difference construction unit is configured to subtract the second feature vector from the first feature vector to obtain a first difference vector, subtract the first feature vector from the second feature vector to obtain a second difference vector, and input the first difference vector and the second difference vector to the prediction unit respectively, the prediction unit is configured to obtain a corresponding prediction score according to the first difference vector or the second difference vector, and the comparison unit is configured to compare the prediction scores to obtain a relative ranking; wherein, model parameters of the prediction unit include variables conforming to a set probability distribution.
[0015] In one of the embodiments, the prediction unit is a multi-layer perceptron structure, and the prediction unit obtains the prediction score according to the following expression:
[0016]
[0017] wherein, h (0) represents an input of the prediction unit, Δ represents the first difference vector or the second difference vector, h (l) represents an output of an lth hidden layer in the multi-layer perceptron structure, W (l) represents a weight matrix of the lth hidden layer in the multi-layer perceptron structure, b (l) represents a bias matrix of the lth hidden layer in the multi-layer perceptron structure, L represents a total number of hidden layers in the multi-layer perceptron structure, σ(·) operator refers to a tanh activation function, and y represents the prediction score, represents a transpose of a weight matrix of an output layer in the multi-layer perceptron structure, b out represents a bias matrix of the output layer in the multi-layer perceptron structure.
[0018] In one of the embodiments, the set probability distribution is a Bernoulli distribution, and the weight matrix of the lth layer in the multi-layer perceptron structure satisfies the Bernoulli distribution q(W (l) ), q(W (l) ) is:
[0019]
[0020] wherein, Ml z represents a learnable parameter i,j is a Bernoulli distribution random variable with probability parameter p i , i = 1,..., L, j = 1,..., h, h represents the total number of neurons contained in the hidden layer, and the diag(·) operator is used to convert a vector into a diagonal matrix.
[0021] In one of the embodiments, the comparison unit is configured to subtract the prediction scores and process the subtraction result by using a sigmoid activation function to obtain the relative ranking.
[0022] In one of the embodiments, the symmetric difference prediction module uses the following loss function during the training process:
[0023]
[0024] wherein, Loss represents the value of the loss function, N is the number of samples in the training set, y ij is the sample label, is the prediction score, λ is an adjustment coefficient, and Φ is a learnable model parameter in the symmetric difference prediction module.
[0025] In one of the embodiments, in the global ranking model, the Bradley-Terry-Luce model framework is used to determine the probability that one target opinion is better than another target opinion, and the Bradley-Terry-Luce model framework uses the intensity parameters of the target opinions as references, wherein the intensity parameters satisfy corresponding probability distributions. The global ranking model constructs a likelihood function according to the relative ranking, and calculates the maximum a posteriori estimation value according to the likelihood function and the probability distributions to estimate the intensity parameters of the target opinions.
[0026] In one of the embodiments, the global ranking model is further configured to estimate each probability distribution by using an expectation propagation algorithm.
[0027] In a second aspect, the present application provides an opinion ranking device, comprising:
[0028] a pairing module configured to combine target opinions in a set of opinions to be ranked in pairs to obtain a plurality of pairs of opinions;
[0029] a relative ranking module configured to input each pair of opinions into a pair of opinion comparison model to obtain the relative ranking of each pair of opinions, wherein the pair of opinion comparison model comprises a feature extraction module and a symmetric difference prediction module, and the model parameters in the symmetric difference prediction module comprise variables conforming to a set probability distribution;
[0030] an intensity prediction module configured to input each relative ranking into a global ranking model to obtain the intensity parameters of the target opinions;
[0031] The global ranking module is configured to rank the target viewpoints according to the strength parameters from high to low.
[0032] In a third aspect, the present application provides a computer device, comprising one or more processors, and a memory, wherein the memory stores computer readable instructions, and the computer readable instructions are executed by the one or more processors to perform the steps of the viewpoint ranking method in any of the above embodiments.
[0033] In a fourth aspect, the present application provides a storage medium, wherein the storage medium stores computer readable instructions, and the computer readable instructions are executed by one or more processors to cause the one or more processors to perform the steps of the viewpoint ranking method in any of the above embodiments.
[0034] From the above technical solutions, the embodiments of the present application have the following advantages:
[0035] The viewpoint ranking method first combines the target viewpoints in the viewpoint set to be ranked in pairs to form multiple pairs of viewpoints, then inputs the pairs of viewpoints into the pair of viewpoint comparison model to obtain relative rankings, then inputs the relative rankings into the global ranking model to calculate the strength parameters of the target viewpoints, and finally ranks the target viewpoints according to the strength parameters. The feature extraction module of the pair of viewpoint comparison model can extract deep features in the original data, and the symmetric difference prediction module also uses parameters containing probability distribution variables, which makes the entire process better adapt to data characteristics and different situations, greatly improving the generalization ability and ranking performance. BRIEF DESCRIPTION OF DRAWINGS
[0036] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiment or prior art description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor.
[0037] Figure 1 The flowchart of the viewpoint ranking method provided by an embodiment of the present application;
[0038] Figure 2 The workflow diagram of the pair of viewpoint comparison model in an embodiment of the present application;
[0039] Figure 3 The workflow diagram of the viewpoint ranking method in an embodiment of the present application;
[0040] Figure 4 The internal structure diagram of the computer device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0041] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0042] The present application provides a viewpoint ranking method, please refer to Figure 1 , comprising steps S102 to S108.
[0043] S102, the target viewpoints in the viewpoint set to be sorted are combined two by two to obtain a plurality of paired viewpoints.
[0044] It can be understood that the viewpoint set to be sorted refers to a set containing a plurality of different viewpoints that need to be sorted, and the viewpoints contained in the viewpoint set to be sorted are target viewpoints. The target viewpoints can be texts on a certain topic, such as financial analysis, medical decision, policy making, etc. They can also be contents with the same or similar index in search engines, databases, and recommendation systems. This step needs to combine these target viewpoints in pairs to form a plurality of different paired viewpoint combinations, such as viewpoints A, B, and C. After two-by-two combination, paired viewpoints such as (A, B), (A, C), and (B, C) are obtained.
[0045] S104, input each paired viewpoint into a paired viewpoint comparison model to obtain the relative ranking of each group of paired viewpoints. The viewpoint comparison model includes a feature extraction module and a symmetric difference prediction module. The model parameters in the symmetric difference prediction module include variables conforming to a set probability distribution.
[0046] It can be understood that the paired viewpoint comparison model is a model specially designed to compare the relative advantages and disadvantages between each pair of viewpoints. It contains a feature extraction module and a symmetric difference prediction module inside. The function of the feature extraction module is to extract key feature information that can represent the characteristics of each pair of viewpoints and their differences from the input paired viewpoints. These features can be category features, numerical features, or other types of descriptive features, etc. The feature extraction module can mine deep features of paired viewpoints, because the original viewpoints can be various in form and complex in content. Through feature extraction, they can be converted into a feature representation form that the model can better understand and process, so that the subsequent symmetric difference prediction module can perform effective comparison and analysis based on these features, and it is also helpful to learn more compact and meaningful opinion representations, capture complex patterns and dependencies that may not be easily distinguished in original features, and improve generalization and prediction performance.
[0047] The symmetric difference prediction module uses the model parameters contained in the extracted features to predict the relative ranking between each pair of opinions, that is, to determine which opinion has higher quality. Another key to improving the generalization ability of the model in this embodiment is that the model parameters of the symmetric difference prediction module are not fixed values. Instead, a probability distribution is introduced to describe the uncertainty of the parameters, making the pairwise opinion comparison model a Bayesian neural network model. Fixed model parameters are prone to overfitting the specific patterns of the training data during training, because the model can only learn and memorize these data features according to fixed parameters. Once encountering data with slightly different characteristics (such as new data in the test set or actual application), the performance of the model may be greatly reduced. However, when the parameters conform to a certain probability distribution, the model will continuously explore different parameter values based on the probability distribution during training. This allows the model to learn a more general feature representation that better reflects the inherent laws of the data, rather than being limited to the surface and local features of the training data, allowing the model to better adapt to different data characteristics and various possible situations.
[0048] S106: Input each relative ranking into a global ranking model to obtain a strength parameter of each target viewpoint.
[0049] It can be understood that relative ranking is the comparison result of which view in each pair of views is superior, as obtained through the pairwise view comparison model. It can be a simple binary judgment (such as 0 or 1 to indicate superiority) or a continuous probability value that reflects relative degree. The global ranking model comprehensively considers the relative ranking information of all pairs of views and then analyzes and calculates the overall strength of each target view. This strength parameter is a quantitative representation of the quality of each target view within the entire set of views to be ranked. It allows different target views to be measured and compared on the same scale based on this strength parameter.
[0050] S108 , sorting the target viewpoints in descending order according to the strength parameters.
[0051] As you can understand, this step, by sorting the strength parameters from high to low, can rank the quality of numerous target opinions, enabling content recommendations, information retrieval, or data screening based on user needs. Alternatively, a certain number of top-ranked opinions can be aggregated, such as compiling analytical reports on a specific stock from different financial analysts to generate a comprehensive forecast. Another example is aggregating the diagnostic opinions of different doctors to provide patients with more accurate treatment plans.
[0052] This opinion ranking method first pairs the target opinions in the opinion set to be ranked into multiple groups of paired opinions. These paired opinions are then input into a pairwise opinion comparison model to obtain relative rankings. Each relative ranking is then input into a global ranking model to calculate the strength parameter for each target opinion. Finally, the target opinions are ranked based on the strength parameter. The feature extraction module of the pairwise opinion comparison model extracts deep features from the raw data, while the symmetric difference prediction module utilizes parameters containing probability distribution variables. This makes the entire process more adaptable to data characteristics and different situations, significantly improving generalization and ranking performance.
[0053] In one embodiment, the feature extraction module includes an embedding layer, a multi-head attention unit, and a flattening layer. It can be understood that the embedding layer is a structure in the deep learning model for converting discrete data into a continuous vector representation of a fixed dimension. The target viewpoint may include categorical features and numerical features. The categorical features can be mapped to the category feature embedding matrix E cat ∈R |C|×d (d is the target dimension), each row in the matrix corresponds to a unique category, and any category feature o ij ∈C can be expressed as Numerical features can be mapped to a vector of target dimension by a learned linear layer. Any numerical feature o ij ∈R can be expressed as ∈R d After the embedding layer, the original n f The i-th view of the feature is transformed into n f ×d embedding feature matrix: E i =[e i1 ,e i2 ,...,e inf ]∈R nf×d .
[0054] The multi-head attention unit is a deep learning module based on the attention mechanism. It aims to simultaneously capture the dependencies and important feature information of different aspects of the input data (that is, the embedded feature matrix output by the embedding layer) from different representation subspaces. The attention mechanism essentially enables the model to focus on certain key parts of the input data. The multi-headed design refers to the use of multiple such attention mechanisms in parallel, each learning a different focus. Finally, these different perspectives are integrated to obtain a more comprehensive and richer feature representation.
[0055] The flattening layer is a simple layer structure used for adjusting the dimension of input data in a deep learning model structure, and its main function is to convert the multi-dimensional input data (here, the attention score output by the multi-head attention unit, which has a certain tensor structure dimension) into a one-dimensional vector form, facilitating further processing and operation of subsequent model structures (such as the symmetric difference prediction module).
[0056] Based on the three structures, each pair of viewpoints is input into a pair of viewpoint comparison model to obtain the relative ranking of each group of pair of viewpoints, including: the two target viewpoints in the pair of viewpoints are input into the feature extraction module to obtain their respective feature vectors. Among them, the embedding layer is used to convert the input target viewpoint into an embedding feature of a target dimension, the multi-head attention unit is used to convert the embedding feature into an attention score, and the flattening layer is used to convert the attention score into a feature vector. A pair of feature vectors is input into the symmetric difference prediction module to obtain the relative ranking.
[0057] In one embodiment, the multi-head attention unit includes a plurality of multi-head attention layers. The multi-head attention layer directly connected with the embedding layer processes the embedding feature using the multi-head attention mechanism and outputs to the next multi-head attention layer. The other multi-head attention layers process the output of the previous multi-head attention layer using the multi-head attention mechanism and output to the next multi-head attention layer.
[0058] It can be understood that the working process of the feature extraction module can be referred to Figure 2 , Figure 2 “FeatureEmbedding” in the above represents the embedding layer, which processes the pair of viewpoints o i and o j and inputs the processing results into the multi-head attention unit. The multi-head attention unit includes a plurality of multi-head attention layers, each of which corresponds to the “Multi-Head SelfAttention” part in the figure, and each contains a plurality of attention heads. Each attention head has corresponding weight matrices W Q , W K , and W V ∈R d×d . Each weight matrix is multiplied by the embedding feature matrix through a linear layer (Linear) to obtain the matrices corresponding to Q, K, and V of the attention head. The attention score of an attention head needs to be obtained by integrating the matrices corresponding to Q, K, and V. It can be represented as:
[0059]
[0060] Among them, represents the attention score of the hth attention head, and E iRepresents the input of this multi-head attention layer, represents the weight matrix corresponding to the h-th attention head Q, represents the weight matrix corresponding to the h-th attention head K, Represents the weight matrix corresponding to the h-th attention head V. These three weight matrices are all learnable model parameters. Attention() represents the process of calculating the attention score based on the input (corresponding to Figure 2 The total attention score M of the i-th view in the multi-head attention layer. i It is necessary to combine the calculation results of all H attention heads (corresponding to Concat in the figure): In some embodiments, in order to maintain the integrity of the input data of each multi-head attention layer, optimize the gradient flow and alleviate the gradient explosion problem, a residual connection (corresponding to the Residual Connection in the figure) is set between the input and output of each multi-head attention layer, so its output can be expressed as: In this embodiment, the embedded features of each opinion are processed sequentially through a set number of multi-head attention layers before obtaining a final attention score that is input into the flattening layer. This iterative processing allows for modeling increasingly complex, higher-order interactions between features, which often contain richer implicit patterns and are crucial for accurately comparing pairwise opinions. In this embodiment, each subsequent multi-head attention layer builds on the output of the previous layer, iteratively refining the feature representation and capturing nonlinear dependencies that might be overlooked in a single-pass approach.
[0061] In one embodiment, the symmetric difference prediction module includes a difference construction unit, a prediction unit and a comparison unit. After the paired viewpoints are input into the feature extraction module, a one-to-one corresponding feature vector is obtained. The two feature vectors are the first feature vector and the second feature vector (e.g. Figure 2 r in oi and r oj ), the difference construction unit is used to subtract the second eigenvector from the first eigenvector to obtain a first difference vector, and to subtract the first eigenvector from the second eigenvector to obtain a second difference vector, and input the first difference vector and the second difference vector into the prediction unit respectively. These two difference vectors capture the difference between the two eigenvectors from different directions, laying the foundation for the subsequent analysis of the relative relationship between the two target viewpoints. The prediction unit is used to obtain a corresponding prediction score based on the first difference vector or the second difference vector. The comparison unit is used to compare the size of the prediction scores to obtain a relative ranking. Among them, the model parameters of the prediction unit include variables that conform to the set probability distribution.
[0062] In one embodiment, the prediction unit is a Multilayer Perceptron structure, and the prediction score is obtained by the prediction unit according to the following expression:
[0063]
[0064] where h (0) represents the input of the prediction unit, and Δ represents the first difference vector or the second difference vector. As shown in the following expression, the first difference vector and the second difference vector are input into the same Multilayer Perceptron structure. Figure 2 The Multilayer Perceptron structure includes L hidden layers, where h (l) represents the output of the l-th hidden layer in the Multilayer Perceptron structure, W (l) represents the weight matrix of the l-th hidden layer in the Multilayer Perceptron structure, b (l) represents the bias matrix of the l-th hidden layer in the Multilayer Perceptron structure, L represents the total number of hidden layers in the Multilayer Perceptron structure, and σ(·) operator represents the tanh activation function. y represents the prediction score, represents the transpose of the weight matrix of the output layer in the Multilayer Perceptron structure, and b out represents the bias matrix of the output layer in the Multilayer Perceptron structure.
[0065] In one embodiment, the traditional neural network has fixed parameter values, can only output point estimates of the prediction target, and is prone to overfitting. In order to obtain better generalization performance in the paired opinion comparison task, the Multilayer Perceptron structure is redefined as a Bayesian model, and a distribution is assigned to each parameter instead of a fixed value. The assigned probability distribution of the Multilayer Perceptron structure is a Bernoulli distribution, and the weight matrix of the l-th layer in the Multilayer Perceptron structure satisfies the Bernoulli distribution q(W (l) ), q(W (l) ) is:
[0066]
[0067] where M l represents the learnable parameter, z i,j is a Bernoulli distribution random variable with a probability parameter p i , i = 1,..., L, j = 1,..., h, and h represents the total number of neurons included in the hidden layer. The diag(·) operator is used to convert a vector into a diagonal matrix. The selection of the probability parameter can be realized by the Monte Carlo Dropout algorithm.
[0068] In one of the embodiments, the comparison unit is configured to subtract the prediction scores and process the result of the subtraction using a sigmoid activation function to obtain the relative ranking. The sigmoid activation function is a common nonlinear function that can map any real number input to a value range between 0 and 1. It is commonly used in deep learning and other fields to convert the output result into a probability form or to normalize the result. In the current scenario, the result processed by the sigmoid activation function represents a quantitative representation of the relative ranking of the two opinions, and a value closer to 1 means that the opinion corresponding to the subtracted number in the prediction score is better, and a value closer to 0 means that the opinion corresponding to the subtracted number in the prediction score is relatively better.
[0069] In one of the embodiments, the following loss function is used in the training process of the symmetric difference prediction module:
[0070]
[0071] wherein Loss represents the value of the loss function, N is the number of samples in the training set, y ij is the sample label, is the prediction score, λ is the adjustment coefficient, and Φ is the learnable model parameter in the symmetric difference prediction module. The training set contains opinion sets for the field and scenario, and the opinion set includes a large number of paired opinions for training, and the sample label of each paired opinion indicates the superiority-inferiority relationship between the two opinions. The learnable model parameter in the symmetric difference prediction module is trained by using the above loss function, thereby completing the training of the symmetric difference prediction module. During training, the AdamW algorithm can be used for optimization, and weight decay can also be used to prevent overfitting. The weight decay can specifically be to set a penalty coefficient for large weight values.
[0072] In one of the embodiments, in the global ranking model, the Bradley-Terry-Luce model framework is used to determine the probability that a target opinion is better than another target opinion, and the Bradley-Terry-Luce model framework uses the intensity parameters of the target opinions as references, wherein the intensity parameters satisfy a corresponding probability distribution. The global ranking model constructs a likelihood function according to the relative ranking, and calculates a maximum a posteriori probability estimate value according to the likelihood function and the probability distribution to estimate the intensity parameters of the target opinions.
[0073] It can be understood that the Bradley-Terry-Luce model framework is a statistical model for modeling paired comparison data, which is commonly used in scenarios such as analyzing competition results and preference ordering. In the context of multiple opinions, the probability that opinion o is better than opinion o i is represented as P(o j | o i ), and the intensity parameters of the opinions are represented as θ , θj Representing the views i and viewpoints j In the global ranking model, it is assumed that the strength parameter of the k-th opinion conforms to a certain probability distribution p(θ k ). The maximum a posteriori probability estimation combines prior knowledge and observation data to estimate the parameters of the model. The relative ranking obtained from the pairwise opinion comparison model is the observation data for ranking the V target opinions. The set of strength parameters of all target viewpoints is taken as the parameter to be determined Θ = (θ1, θ2, ..., θ V ), we can use the maximum a posteriori probability estimation method to estimate Θ, that is, in is the set of estimated intensity parameters. α is a hyperparameter related to the probability distribution of each intensity parameter. According to Bayes’ theorem and the n ,α) to obtain the logarithm logP(Θ|D n ,α)=logP(D n |Θ)+logP(Θ|α)+const, the constant term can be ignored, and the first term is the likelihood function, which means that the data D is observed under given parameters Θ n The second term is the logarithm of the probability distribution of Θ. The likelihood function can be constructed based on relative rankings. Specifically, each relative ranking corresponds to a term in the likelihood function, and each term represents the probability of that relative ranking within the Bradley-Terry-Luce model. Multiplying these terms together yields the likelihood function associated with Θ. The hyperparameters in the probability distribution of the second term can be fixed. However, they can also be estimated using the expectation propagation algorithm.
[0074] In a specific embodiment, the global ranking model is also used to estimate each probability distribution using the expectation propagation algorithm. The complete workflow of this embodiment is as follows: Figure 3 As shown. It is often very difficult to directly calculate the probability distribution of the intensity parameter. The expectation propagation algorithm is a method for approximating the difficult probability distribution with the easy-to-handle probability distribution. It approximates the true probability distribution through iteration. Specifically, assuming p(θ k ) satisfies the isotropic Gaussian distribution, that is, An approximate probability distribution is set for each intensity parameter: q(θ) = N(θ; μ, C). θ represents the set of each intensity parameter, μ represents the mean matrix of the approximate probability distribution, and C represents the covariance matrix of the approximate probability distribution. During the process of the expectation propagation algorithm, the construction of the cavity distribution, the matrix matching, the updating of the model parameters, etc. are involved. In this process, each intensity parameter is processed as a factor, and the construction of the cavity distribution is to remove the natural parameters (τ ij ,υ ij ) in the precision matrix P and the auxiliary vector x of the current factor in the weight space. Then, the mean matrix μ cav and the covariance matrix C cav of the approximate probability distribution are recalculated. Then, the first derivative and the second derivative of the standard normal cumulative distribution function Φ(z) in the logarithm are calculated. Then, the new natural parameters of the current factor are generated using the two results:
[0075]
[0076] The new natural parameters of the current factor are added to the weight space again. Based on the latest weight space, the mean matrix and the covariance matrix of q(θ) are also updated. Whether the convergence of the entire iteration process is based on the difference between the natural parameters of the previous and the next rounds. If the difference is lower than the set threshold, the current factor is updated, and the next factor is selected for updating, until all the factors are updated.
[0077] The application provides a viewpoint ranking device, which comprises a pairing module, a relative ranking module, an intensity prediction module, and a global ranking module.
[0078] The pairing module is used for combining target viewpoints in a viewpoint set to be ranked two by two to obtain multiple pairs of viewpoints. The relative ranking module inputs each pair of viewpoints into a pair of viewpoint comparison model to obtain the relative ranking of each pair of viewpoints. The viewpoint comparison model comprises a feature extraction module and a symmetric difference prediction module, and the model parameters in the symmetric difference prediction module comprise variables conforming to a set probability distribution. The intensity prediction module is used for inputting each relative ranking into a global ranking model to obtain the intensity parameters of each target viewpoint. The global ranking module is used for ranking the target viewpoints according to the order from high to low of the intensity parameters.
[0079] The specific limitations of the opinion ranking device can refer to the limitations of the opinion ranking method described above, which will not be repeated here. Each module in the above opinion ranking device can be implemented by software, hardware, and a combination thereof, in whole or in part. The above modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor invokes and executes the operations corresponding to each of the above modules. It should be noted that the division of modules in the embodiments of the present application is illustrative, and is only a logical functional division. In actual implementation, there can be another division manner.
[0080] The present application provides a computer device, comprising one or more processors, and a memory, the memory storing computer readable instructions, when the computer readable instructions are executed by the one or more processors, performing: combining target opinions in a set of opinions to be ranked two by two to obtain a plurality of pairs of opinions; inputting each pair of opinions into a pair of opinion comparison model to obtain a relative ranking of each pair of opinions; the opinion comparison model comprises a feature extraction module and a symmetric difference prediction module, the model parameters in the symmetric difference prediction module comprise variables conforming to a set probability distribution; inputting each relative ranking into a global ranking model to obtain a strength parameter of each target opinion; and ranking the target opinions according to the order from high to low of the strength parameters.
[0081] In one embodiment, the feature extraction module comprises an embedding layer, a multi-head attention unit, and a flattening layer; inputting each pair of opinions into the pair of opinion comparison model to obtain a relative ranking of each pair of opinions comprises: inputting two target opinions in the pair of opinions into the feature extraction module respectively to obtain respective corresponding feature vectors; wherein the embedding layer is used to convert the input target opinions into embedding features of a target dimension, the multi-head attention unit is used to convert the embedding features into attention scores, and the flattening layer is used to convert the attention scores into feature vectors; inputting a pair of feature vectors into the symmetric difference prediction module to obtain a relative ranking.
[0082] In one embodiment, the multi-head attention unit comprises a plurality of multi-head attention layers, and the multi-head attention layer directly connected with the embedding layer processes the embedding features using the multi-head attention mechanism and outputs to the next multi-head attention layer, and the other multi-head attention layers process the output of the previous multi-head attention layer using the multi-head attention mechanism and output to the next multi-head attention layer.
[0083] In one embodiment, a residual connection is provided between the input and the output of each multi-head attention layer.
[0084] In one of the embodiments, the symmetric difference prediction module comprises a difference construction unit, a prediction unit and a comparison unit, a pair of feature vectors comprises a first feature vector and a second feature vector, the difference construction unit is configured to subtract the second feature vector from the first feature vector to obtain a first difference vector, subtract the first feature vector from the second feature vector to obtain a second difference vector, and input the first difference vector and the second difference vector into the prediction unit respectively, the prediction unit is configured to obtain a corresponding prediction score according to the first difference vector or the second difference vector, and the comparison unit is configured to compare the prediction scores to obtain a relative ranking, wherein a model parameter of the prediction unit comprises a variable conforming to a set probability distribution.
[0085] In one of the embodiments, the prediction unit is a multi-layer perception structure, and the prediction unit obtains the prediction score according to the following expression:
[0086]
[0087] wherein h (0) represents an input of the prediction unit, Δ represents the first difference vector or the second difference vector, h (l) represents an output of an lth hidden layer in the multi-layer perception structure, W (l) represents a weight matrix of the lth hidden layer in the multi-layer perception structure, b (l) represents a bias matrix of the lth hidden layer in the multi-layer perception structure, L represents a total number of hidden layers in the multi-layer perception structure, and σ(·) operator refers to a tanh activation function, y represents the prediction score, represents a transpose of a weight matrix of an output layer in the multi-layer perception structure, b out represents a bias matrix of the output layer in the multi-layer perception structure.
[0088] In one of the embodiments, the set probability distribution is a Bernoulli distribution, and the weight matrix of the lth layer in the multi-layer perception structure satisfies the Bernoulli distribution q(W (l) ), and q(W (l) ) is:
[0089]
[0090] wherein M l represents a learnable parameter, z i,j is a Bernoulli distribution random variable with a probability parameter p i , i = 1,..., L, j = 1,..., h, and h represents a total number of neurons contained in the hidden layer, and diag(·) operator is used to convert a vector into a diagonal matrix.
[0091] In one of the embodiments, the comparison unit is configured to subtract the prediction scores, and process a result of the subtraction by using a sigmoid activation function to obtain the relative ranking.
[0092] In one embodiment, the following loss function is used during the training of the symmetric difference prediction module:
[0093]
[0094] Among them, Loss represents the value of the loss function, N is the number of samples in the training set, and y ij is the sample label, is the predicted score, λ is the adjustment coefficient, and Φ is the learnable model parameter in the symmetric difference prediction module.
[0095] In one embodiment, in a global ranking model, the probability that one target viewpoint outperforms another target viewpoint is determined using a Bradley-Terry-Luce model framework. The Bradley-Terry-Luce model framework uses the strength parameters of each target viewpoint as a reference, where each strength parameter satisfies a corresponding probability distribution. The global ranking model constructs a likelihood function based on the relative ranking, and calculates the maximum a posteriori probability estimate based on the likelihood function and the probability distribution to estimate the strength parameters of each target viewpoint.
[0096] In one embodiment, the global ranking model is further used to estimate each probability distribution using an expectation propagation algorithm.
[0097] Schematically, as Figure 4 As shown, Figure 4 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. Figure 4 Computer device 400 includes a processing component 402, which further includes one or more processors, and memory resources represented by memory 401 for storing instructions executable by processing component 402, such as an application. The application stored in memory 401 may include one or more modules, each corresponding to a set of instructions. In addition, processing component 402 is configured to execute the instructions to perform the steps of the opinion ranking method of any of the above-described embodiments.
[0098] The computer device 400 may further include a power supply component 403 configured to perform power management of the computer device 400 , a wired or wireless model interface 404 configured to connect the computer device 400 to the model, and an input / output (I / O) interface 405 .
[0099] The application provides a storage medium, which stores computer readable instructions. When the computer readable instructions are executed by one or more processors, the one or more processors perform: combining target viewpoints in a viewpoint set to be sorted two by two to obtain a plurality of pairs of viewpoints; inputting each pair of viewpoints into a pair of viewpoint comparison model to obtain a relative ranking of each pair of viewpoints; the viewpoint comparison model comprises a feature extraction module and a symmetric difference prediction module, and model parameters in the symmetric difference prediction module comprise variables conforming to a set probability distribution; inputting each relative ranking into a global ranking model to obtain a strength parameter of each target viewpoint; and sorting the target viewpoints according to the order from high to low of the strength parameters.
[0100] In one of the embodiments, the feature extraction module comprises an embedding layer, a multi-head attention unit and a flattening layer; the inputting each pair of viewpoints into the pair of viewpoint comparison model to obtain a relative ranking of each pair of viewpoints comprises: inputting two target viewpoints in the pair of viewpoints into the feature extraction module respectively to obtain respective corresponding feature vectors; wherein the embedding layer is used to convert the input target viewpoints into embedding features of a target dimension, the multi-head attention unit is used to convert the embedding features into attention scores, and the flattening layer is used to convert the attention scores into the feature vectors; and the inputting a pair of feature vectors into the symmetric difference prediction module to obtain a relative ranking.
[0101] In one of the embodiments, the multi-head attention unit comprises a plurality of multi-head attention layers, a multi-head attention layer directly connected with the embedding layer processes the embedding features by using a multi-head attention mechanism and outputs to a next multi-head attention layer, and other multi-head attention layers process the output of a previous multi-head attention layer by using a multi-head attention mechanism and output to a next multi-head attention layer.
[0102] In one of the embodiments, a residual connection is arranged between the input and the output of each multi-head attention layer.
[0103] In one of the embodiments, the symmetric difference prediction module comprises a difference construction unit, a prediction unit and a comparison unit, a pair of feature vectors comprises a first feature vector and a second feature vector, the difference construction unit is used to subtract the second feature vector from the first feature vector to obtain a first difference vector, subtract the first feature vector from the second feature vector to obtain a second difference vector, and input the first difference vector and the second difference vector into the prediction unit respectively, the prediction unit is used to obtain a corresponding prediction score according to the first difference vector or the second difference vector; and the comparison unit is used to compare the sizes of the prediction scores to obtain a relative ranking; wherein the model parameters of the prediction unit comprise variables conforming to a set probability distribution.
[0104] In one of the embodiments, the prediction unit is a multi-layer perception structure, and the prediction unit obtains a prediction score according to the following expression:
[0105]
[0106] where h (0) represents the input of the prediction unit, Δ represents the first difference vector or the second difference vector, h (l) represents the output of the lth hidden layer in the multi-layer perceptron structure, W (l) represents the weight matrix of the lth hidden layer in the multi-layer perceptron structure, b (l) represents the bias matrix of the lth hidden layer in the multi-layer perceptron structure, L represents the total number of hidden layers in the multi-layer perceptron structure, the σ(·) operator refers to the tanh activation function, and y represents the prediction score, represents the transpose of the weight matrix of the output layer in the multi-layer perceptron structure, b out represents the bias matrix of the output layer in the multi-layer perceptron structure.
[0107] In one embodiment, the probability distribution is set as a Bernoulli distribution, and the weight matrix of the lth layer in the multi-layer perceptron structure satisfies the Bernoulli distribution q(W (l) ), q(W (l) ) is:
[0108]
[0109] where M l represents a learnable parameter, z i,j is a Bernoulli distribution random variable with a probability parameter p i , i = 1,..., L, j = 1,..., h, h represents the total number of neurons contained in the hidden layer, and the diag(·) operator is used to convert a vector into a diagonal matrix.
[0110] In one embodiment, the comparison unit is used to subtract the prediction scores and process the result of subtraction using a sigmoid activation function to obtain a relative ranking.
[0111] In one embodiment, the following loss function is used in the training process of the symmetric difference prediction module:
[0112]
[0113] where Loss represents the value of the loss function, N is the number of samples in the training set, y ij is the sample label, is the prediction score, λ is an adjustment coefficient, and Φ is a learnable model parameter in the symmetric difference prediction module.
[0114] In one embodiment, in a global ranking model, the probability that one target viewpoint outperforms another target viewpoint is determined using a Bradley-Terry-Luce model framework. The Bradley-Terry-Luce model framework uses the strength parameters of each target viewpoint as a reference, where each strength parameter satisfies a corresponding probability distribution. The global ranking model constructs a likelihood function based on the relative ranking, and calculates the maximum a posteriori probability estimate based on the likelihood function and the probability distribution to estimate the strength parameters of each target viewpoint.
[0115] In one embodiment, the global ranking model is further used to estimate each probability distribution using an expectation propagation algorithm.
[0116] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or device comprising the element.
[0117] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referenced to each other.
[0118] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for ranking opinions, characterized in that: include: Combine the target opinions in the opinion set to be sorted in pairs to obtain multiple groups of paired opinions; Inputting each of the paired viewpoints into a paired viewpoint comparison model to obtain a relative ranking of each group of the paired viewpoints; the viewpoint comparison model includes a feature extraction module and a symmetric difference prediction module, and the model parameters in the symmetric difference prediction module include variables that conform to a set probability distribution; Inputting each of the relative rankings into a global ranking model to obtain a strength parameter of each of the target viewpoints; sorting the target viewpoints according to the strength parameter in descending order; The feature extraction module includes an embedding layer, a multi-head attention unit and a flattening layer; Inputting each of the paired viewpoints into a paired viewpoint comparison model to obtain a relative ranking of each group of the paired viewpoints includes: Inputting the two target viewpoints in the paired viewpoints into the feature extraction module respectively to obtain respective corresponding feature vectors; wherein the embedding layer is used to convert the input target viewpoints into embedded features of the target dimension, the multi-head attention unit is used to convert the embedded features into attention scores, and the flattening layer is used to convert the attention scores into the feature vectors; Inputting a pair of the feature vectors into the symmetric difference prediction module to obtain the relative ranking; The symmetric differential prediction module includes a differential construction unit, a prediction unit and a comparison unit. The pair of eigenvectors includes a first eigenvector and a second eigenvector. The differential construction unit is used to subtract the second eigenvector from the first eigenvector to obtain a first differential vector, and to subtract the first eigenvector from the second eigenvector to obtain a second differential vector, and input the first differential vector and the second differential vector into the prediction unit respectively. The prediction unit is used to obtain a corresponding prediction score based on the first differential vector or the second differential vector; the comparison unit is used to compare the sizes of the prediction scores to obtain the relative ranking; wherein, the model parameters of the prediction unit include variables that conform to the set probability distribution.
2. The opinion ranking method according to claim 1, characterized in that: The multi-head attention unit includes multiple multi-head attention layers. The multi-head attention layer directly connected to the embedding layer uses a multi-head attention mechanism to process the embedded features and outputs them to the next multi-head attention layer. The other multi-head attention layers use a multi-head attention mechanism to process the output of the previous multi-head attention layer and output it to the next multi-head attention layer.
3. The opinion ranking method according to claim 2, characterized in that: A residual connection is set between the input and output of each multi-head attention layer.
4. The opinion ranking method according to claim 1, characterized in that: The prediction unit is a multi-layer perceptron structure, and the prediction unit obtains the prediction score according to the following expression: ; in, represents the prediction unit input, represents the first difference vector or the second difference vector, Represents the output of the lth hidden layer in the multi-layer perceptron structure, Represents the weight matrix of the lth hidden layer in the multilayer perceptron structure, Represents the bias matrix of the lth hidden layer in the multilayer perceptron structure, L represents the total number of hidden layers in the multilayer perceptron structure, The operator refers to the tanh activation function, y represents the predicted score, Represents the transpose of the weight matrix of the output layer in the multilayer perceptron structure, Represents the bias matrix of the output layer in the multilayer perceptron structure.
5. The opinion ranking method according to claim 4, characterized in that: The probability distribution is set to Bernoulli distribution, and the weight matrix of the first layer in the multi-layer perceptron structure satisfies the Bernoulli distribution. , for: ; in, represents the learnable parameters, The probability parameter is Bernoulli distributed random variables, i=1,...,L, j=1,...,h, h represents the total number of neurons in the hidden layer, operator is used to convert a vector into a diagonal matrix.
6. The opinion ranking method according to claim 1, characterized in that: The comparison unit is used to subtract the predicted scores and process the subtraction result using a sigmoid activation function to obtain the relative ranking.
7. The opinion ranking method according to claim 1, characterized in that: The following loss function is used during the training of the symmetric difference prediction module: ; Among them, Loss represents the value of the loss function, N is the number of samples in the training set, is the sample label, is the predicted score, is the adjustment coefficient, are learnable model parameters in the symmetric difference prediction module.
8. The opinion ranking method according to claim 1, characterized in that: In the global ranking model, the probability that one target viewpoint outperforms another target viewpoint is determined using the Bradley-Terry-Luce model framework. The Bradley-Terry-Luce model framework uses the intensity parameters of each target viewpoint as a reference, wherein each intensity parameter satisfies the corresponding probability distribution. The global ranking model constructs a likelihood function based on the relative ranking, and calculates the maximum a posteriori probability estimate based on the likelihood function and the probability distribution to estimate the intensity parameters of each target viewpoint.
9. The opinion ranking method according to claim 8, characterized in that: The global ranking model is further used to estimate each of the probability distributions using an expectation propagation algorithm.
10. A viewpoint ranking device, characterized in that: include: The pairing module is used to combine the target opinions in the opinion set to be sorted into pairs to obtain multiple groups of paired opinions; a relative ranking module that inputs each of the paired viewpoints into a paired viewpoint comparison model to obtain a relative ranking of each group of the paired viewpoints; the viewpoint comparison model includes a feature extraction module and a symmetric difference prediction module, and the model parameters in the symmetric difference prediction module include variables that conform to a set probability distribution; A strength prediction module, configured to input each of the relative rankings into a global ranking model to obtain a strength parameter of each of the target viewpoints; a global ranking module, configured to rank the target viewpoints in descending order according to the strength parameters; The feature extraction module includes an embedding layer, a multi-head attention unit, and a flattening layer; the relative ranking module is specifically used to input the two target viewpoints in the pair of viewpoints into the feature extraction module respectively to obtain the corresponding feature vectors; wherein, the embedding layer is used to convert the input target viewpoint into an embedded feature of the target dimension, the multi-head attention unit is used to convert the embedded feature into an attention score, and the flattening layer is used to convert the attention score into the feature vector; a pair of the feature vectors is input into the symmetric difference prediction module to obtain the relative ranking; The symmetric differential prediction module includes a differential construction unit, a prediction unit and a comparison unit. The pair of eigenvectors includes a first eigenvector and a second eigenvector. The differential construction unit is used to subtract the second eigenvector from the first eigenvector to obtain a first differential vector, and to subtract the first eigenvector from the second eigenvector to obtain a second differential vector, and input the first differential vector and the second differential vector into the prediction unit respectively. The prediction unit is used to obtain a corresponding prediction score based on the first differential vector or the second differential vector; the comparison unit is used to compare the sizes of the prediction scores to obtain the relative ranking; wherein, the model parameters of the prediction unit include variables that conform to the set probability distribution.
11. A computer device, characterized in that: The system comprises one or more processors and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the opinion ranking method according to any one of claims 1 to 9 are performed.
12. A storage medium, characterized in that: The storage medium stores computer-readable instructions, which, when executed by one or more processors, enable the one or more processors to perform the steps of the opinion ranking method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Text sorting method for mixing point-by-point strategy and pairwise strategy
CN108717434A
Video searching
WO2013021176A1