A clause recommendation method, device, equipment and readable storage medium

By encoding event text and candidate entries using a self-attention text encoder, calculating fine-grained and coarse-grained matching scores, and combining a weighted summation method, the problem of inaccurate and inefficient entry recommendation in existing technologies is solved, achieving efficient and accurate entry recommendation.

CN114756672BActive Publication Date: 2025-10-21BEIJING BEIDA SOFTWARE ENG DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210470651.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-28
Publication Date
2025-10-21
Estimated Expiration
2042-04-28

AI Technical Summary

Technical Problem

In the field of text matching, due to the length and volume of text, existing technologies cannot accurately and efficiently recommend content to users, resulting in inaccurate matching results and low efficiency.

Method used

The event text and candidate entries are encoded by a self-attention text encoder. The vector of each word is calculated and fine-grained and coarse-grained matching scores are obtained. Combined with a weighted summation method, a preset number of entries are recommended from the candidate entry set.

Benefits of technology

It enables more accurate and efficient recommendation of clauses, improving the accuracy and efficiency of matching.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114756672B_ABST
    Figure CN114756672B_ABST
Patent Text Reader

Abstract

The application provides a clause recommendation method, device and equipment and a readable storage medium. The method comprises the following steps: performing matching degree matching on a vector of each word in a plurality of words corresponding to event text and vectors of all words in each clause in a candidate clause set, respectively, to obtain a fine-grained matching score of each clause and the event text; performing matching degree matching on the vector corresponding to the event text and the vector of each clause in the candidate clause set, respectively, to obtain a coarse-grained matching score of each clause and the event text; and determining a preset number of recommended clauses from the candidate clause set based on the fine-grained matching scores of all clauses in the candidate clause set and the event text and the coarse-grained matching scores of each clause and the event text. The method can achieve the effect of accurately and efficiently recommending clauses.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of relevant article recommendation, and in particular, to a method, apparatus, device and readable storage medium for article recommendation. Background Art

[0002] With the rapid development of the internet and the widespread adoption of document management, most businesses and related departments have entered the document management era. Large amounts of text information can be automatically processed through machine learning and artificial intelligence, greatly simplifying traditional manual processing and improving the efficiency of various departments.

[0003] However, in the field of text matching, in the traditional processing flow, it is necessary to use a pre-trained language model to recommend a series of article text information to users by matching the vector corresponding to the event text with the article text vector.

[0004] However, in the actual text matching process, due to the long text and large number of texts, the final matching results are inaccurate, inefficient, and take a long time to match.

[0005] Therefore, how to accurately and efficiently recommend articles to users based on event text is a technical problem that needs to be solved. Summary of the Invention

[0006] The purpose of the embodiments of the present application is to provide a method for recommending articles. Through the technical solutions of the embodiments of the present application, it is possible to achieve the effect of accurately and efficiently recommending articles to users.

[0007] In the first aspect, an embodiment of the present application provides a method for article recommendation, including matching the vector of each word in the multiple words corresponding to the event text with the vectors of all words in each article in the candidate article set, to obtain a fine-grained matching score between each article and the event text; matching the vector corresponding to the event text with the vector of each article in the candidate article set, to obtain a coarse-grained matching score between each article and the event text; and determining a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set and the event text and the coarse-grained matching scores of each article and the event text.

[0008] In the above process, the fine-grained matching score between each article and the event text can be calculated in a fine-grained manner, and finally the articles can be filtered according to the score. Through a finer-grained matching mechanism and scoring the matching results, the solution of this application can achieve the effect of accurately and efficiently recommending articles.

[0009] In one embodiment, a preset number of recommended articles are determined from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text, including:

[0010] The fine-grained matching scores of all clauses in the candidate clause set and the event text and the coarse-grained matching scores of all clauses in the candidate clause set and the event text are weighted and summed to obtain the total matching score corresponding to each clause in the candidate clause set;

[0011] A preset number of recommended articles are determined from the candidate article set based on the total matching score corresponding to each article in the candidate article set.

[0012] In the above process, the coarse-grained matching scores between each article and the event text are used to screen the articles, and the fine-grained matching scores between all articles in the candidate article set and the event text are weighted summed. Articles are recommended based on the total score after the weighted summation, making the final recommendation results more accurate.

[0013] In one embodiment, before performing matching based on the vector corresponding to the event text and the vector of each article in the candidate article set to obtain a coarse-grained matching score between each article and the event text, the following steps are further included:

[0014] Use the pre-trained self-attention text encoder to encode the event text and each article in the candidate article set, and obtain the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set;

[0015] Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain the vector corresponding to the event text;

[0016] The vectors of all words in each article in the candidate article set are aggregated separately to obtain the vector of each article in the candidate article set.

[0017] In the above process, the self-attention text encoder obtained through continuous training is used to obtain the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set, and the vectors corresponding to the event text and the vectors of each article in the candidate article set are aggregated separately, which have higher accuracy.

[0018] In one embodiment, before respectively performing degree matching on the vectors of each of the multiple words corresponding to the event text and the vectors of all the words of each article in the candidate article set to obtain a fine-grained matching score between each article and the event text, the following steps are further included:

[0019] The pre-trained self-attention text encoder is used to encode the event text and each article in the candidate article set to obtain the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set.

[0020] In the above process, the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set obtained by the trained self-attention text encoder are more accurate.

[0021] In one embodiment, before respectively performing degree matching on the vectors of each of the multiple words corresponding to the event text and the vectors of all the words of each article in the candidate article set to obtain a fine-grained matching score between each article and the event text, the following steps are further included:

[0022] Use the pre-trained self-attention text encoder to encode the event text and obtain the vector of each word in the multiple words corresponding to the event text;

[0023] Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain the vector corresponding to the event text;

[0024] Use the event text classifier to process the vector corresponding to the event text to obtain a set of text names related to the event text;

[0025] A preset number of text names are filtered out from the text name set, and the clause corresponding to each text name is obtained to obtain a candidate clause set.

[0026] In the above process, the vector corresponding to the aggregated event text is then processed by the event text classifier, which can prioritize which text names in the text names to which the event text belongs, and quickly obtain a set of candidate clauses based on the determined text names.

[0027] In one embodiment, the vector of each of the multiple words corresponding to the event text is matched with the vectors of all the words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text, including:

[0028] Perform matching on the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set, and obtain a matching score for the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set;

[0029] Each clause in the candidate clause set undergoes the following steps to obtain a fine-grained matching score between each clause in the candidate clause set and the event text:

[0030] The vector of each of the multiple words corresponding to the event text and the vector of all words in the Nth article in the candidate article set with the highest matching score are summed to obtain the matching score between the event text and the Nth article, where N is a positive integer greater than or equal to 1.

[0031] In the above process, the sum of the scores corresponding to each of the multiple words in the event text and the Nth article is used as the fine-grained score of the event text and the article. The fine-grained matching score between each article in the candidate article set and the event text obtained by this method is more representative, making the final recommended article result more accurate.

[0032] In one embodiment, a preset number of recommended articles are determined from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text, including:

[0033] Based on the fine-grained matching scores of all articles in the candidate article set and the event text, each article in the candidate article set is sorted from high score to low score to obtain a sorted queue, and a preset number of recommended articles are determined starting from the first one in the queue.

[0034] In the above process, the articles are sorted according to the scores, and a certain number of the first few articles are taken as the final screening results. The screened articles are more consistent with the description of the event text.

[0035] In a second aspect, an embodiment of the present application provides a device for recommending clauses, including:

[0036] A matching module is used to match the vector of each word in the multiple words corresponding to the event text with the vector of all words in each article in the candidate article set, and obtain a fine-grained matching score between each article and the event text;

[0037] The second matching module is used to match the vector corresponding to the event text with the vector of each article in the candidate article set, and obtain a coarse-grained matching score between each article and the event text;

[0038] The recommendation module is used to determine a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text.

[0039] Optionally, the recommendation module is specifically used to:

[0040] The fine-grained matching scores of all clauses in the candidate clause set and the event text and the coarse-grained matching scores of all clauses in the candidate clause set and the event text are weighted and summed to obtain the total matching score corresponding to each clause in the candidate clause set;

[0041] A preset number of recommended articles are determined from the candidate article set based on the total matching score corresponding to each article in the candidate article set.

[0042] Optionally, the device further includes:

[0043] an aggregation module for performing, before the second matching module performs degree matching on the vector corresponding to the event text and the vector of each article in the candidate article set to obtain a coarse-grained matching score between each article and the event text, an aggregation module for encoding the event text and each article in the candidate article set using a pre-trained self-attention text encoder to obtain a vector for each of the multiple words corresponding to the event text and a vector for all words in each article in the candidate article set;

[0044] Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain the vector corresponding to the event text;

[0045] The vectors of all words in each article in the candidate article set are aggregated separately to obtain the vector of each article in the candidate article set.

[0046] Optionally, the device further includes:

[0047] The encoding module is used for the matching module to use a pre-trained self-attention text encoder to encode the event text and each article in the candidate article set before matching the vector of each word in the multiple words corresponding to the event text with the vectors of all words in each article in the candidate article set to obtain the fine-grained matching score of each article with the event text, thereby obtaining the vector of each word in the multiple words corresponding to the event text and the vectors of all words in each article in the candidate article set.

[0048] Optionally, the device further includes:

[0049] An acquisition module is configured to encode the event text using a pre-trained self-attention text encoder to obtain a vector for each of the multiple words corresponding to the event text, before the matching module performs degree matching on the vectors of each word in the multiple words corresponding to the event text and the vectors of all words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text;

[0050] Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain the vector corresponding to the event text;

[0051] Use the event text classifier to process the vector corresponding to the event text to obtain a set of text names related to the event text;

[0052] A preset number of text names are filtered out from the text name set, and the clause corresponding to each text name is obtained to obtain a candidate clause set.

[0053] Optionally, the matching module is specifically configured to:

[0054] Perform matching on the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set, and obtain a matching score for the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set;

[0055] Each clause in the candidate clause set undergoes the following steps to obtain a fine-grained matching score between each clause in the candidate clause set and the event text:

[0056] The vector of each of the multiple words corresponding to the event text and the vector of all words in the Nth article in the candidate article set with the highest matching score are summed to obtain the matching score between the event text and the Nth article, where N is a positive integer greater than or equal to 1.

[0057] Optionally, the recommendation module is specifically used to:

[0058] Based on the fine-grained matching scores of all articles in the candidate article set and the event text, each article in the candidate article set is sorted from high score to low score to obtain a sorted queue, and a preset number of recommended articles are determined starting from the first one in the queue.

[0059] In a third aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, wherein the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, the steps in the method provided in the first aspect above are executed.

[0060] In a fourth aspect, an embodiment of the present application provides a readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps in the method provided in the first aspect are executed.

[0061] Other features and advantages of the present application will be described in the following description and, in part, will become apparent from the description or be understood by practicing the embodiments of the present application. The objectives and other advantages of the present application can be achieved and obtained through the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0063] Figure 1 A flowchart of a method for recommending clauses provided in an embodiment of the present application;

[0064] Figure 2 A schematic diagram of a method for obtaining a vector corresponding to an event text provided in an embodiment of the present application;

[0065] Figure 3 A schematic diagram of a method for article recommendation based on fine-grained text matching provided in an embodiment of the present application;

[0066] Figure 4 A schematic diagram of a method for obtaining a total matching score between an event text and an article text provided in an embodiment of the present application;

[0067] Figure 5 A schematic block diagram of a device for recommending clauses provided in an embodiment of the present application;

[0068] Figure 6 A schematic block diagram of the structure of a device for recommending clauses provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] The technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all of the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work fall within the scope of protection of the present application.

[0070] It should be noted that similar reference numerals and letters represent similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and should not be understood as indicating or implying relative importance.

[0071] This application is applied to the scenario of recommending relevant articles. The specific scenario is to screen out the articles that best match the description of the event text from a large number of articles based on the description of the event text.

[0072] However, the current article recommendation process requires manual judgment on which articles match the event text description, or the use of pre-trained language models to match the event text vector with the article text vector to recommend a series of article text information. However, due to the length and large number of texts in the actual article recommendation process, the final matching results are inaccurate, inefficient, and time-consuming.

[0073] To this end, this application performs degree matching on the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set, respectively, to obtain a fine-grained matching score between each article and the event text, and screens the corresponding articles based on the fine-grained matching score of the articles. It is also possible to perform degree matching based on the vectors corresponding to the event text and the vectors of each article in the candidate article set, respectively, to obtain a coarse-grained matching score between each article and the event text; perform weighted summation of the fine-grained matching scores of all articles in the candidate article set and the event text and the coarse-grained matching scores of all articles in the candidate article set and the event text, to obtain a total matching score corresponding to each article in the candidate article set, and screen and recommend the corresponding articles based on the score after the weighted summation of the fine-grained matching scores and the coarse-grained matching scores of the articles, so as to achieve the effect of accurately and efficiently recommending articles.

[0074] In the embodiment of the present application, the execution entity may be a clause recommendation device in the clause recommendation system. In actual applications, the clause recommendation device may be an electronic device such as a terminal device and a server device, which is not limited here.

[0075] The following combination Figure 1 The method recommended by the clauses of the embodiments of this application is described in detail.

[0076] Please see Figure 1 , Figure 1 A flowchart of a method for recommending a clause provided in an embodiment of the present application is shown in FIG. Figure 1 The methods recommended by the provisions shown include:

[0077] Step 110: perform matching on the vector of each word in the multiple words corresponding to the event text and the vectors of all words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text.

[0078] In the above process, the fine-grained matching score between each clause and the event text can be calculated in a fine-grained manner, and finally the clauses can be filtered according to the score. Through a finer-grained matching mechanism and scoring the matching results, the conformity between the event text and each clause can be determined more reasonably.

[0079] Among them, the multiple words corresponding to the event text can be part of the words in the event text, for example, some key words, or a preset number of words, or all the words in the event text. The matching score can be determined based on the similarity of the two vectors or the size of the cosine value. The event text can be a description of a case, a description of a company's system, a description of a class's system, and a description of a traffic incident, etc. The corresponding provisions can be legal provisions, company regulations, class rules, or traffic regulations, etc. All relevant rules-related provisions fall within the scope of protection of this application, and this application is not limited thereto.

[0080] In addition, the present application can not only perform degree matching based on the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set, obtain a fine-grained matching score between each article and the event text and screen the articles, but also can perform degree matching based on other scores, for example, perform degree matching based on the vector corresponding to the event text and the vector of each article in the candidate article set, obtain a coarse-grained matching score between each article and the event text to screen the articles, or screen the articles based on the above two different scores, or the total score obtained by weighted summation of more relevant scores, but the present application is not limited to this.

[0081] Specifically, before executing step 110, the following steps may be performed:

[0082] The pre-trained self-attention text encoder is used to encode the event text and each article in the candidate article set to obtain the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set.

[0083] In the above process, the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set obtained by the trained self-attention text encoder are more accurate.

[0084] Among them, the trained self-attention text encoder can be continuously trained based on the historical articles in the database, and the encoding result is more accurate. The vector of each word can be calculated by the following formula:

[0085]

[0086]

[0087] h i =Concat(head i,1 ,…,head i,h ).

[0088] Among them, W is a trainable parameter, Attention represents attention, Q, K, V represent the input vector of the multi-head attention mechanism module, softmax is a logistic regression model, Concat is a vector calculation function, e i Represents the input word vector, i represents the vector of the i-th word, k represents the output vector of the k-th attention head, head i,k represents the output vector of the i-th word vector after the k-th attention head, i and k are positive integers greater than or equal to 1, h i is the context vector representation of each word in the article text, d represents the word vector dimension, and T is used for matrix transposition. In addition, in the text description, the vector representation of each word can be calculated based on the importance of the word at different positions. The specific value of the importance of each position can be obtained using the following formula:

[0089]

[0090]

[0091] Among them, t represents the position of the word in the text, d is the dimension of the word vector, and timing (t,i) The value representing the importance of the i-th position in the word vector of the t-th word.

[0092] Specifically, before executing step 110, the following steps may be performed:

[0093] Step 111: Encode the event text using a pre-trained self-attention text encoder to obtain a vector for each of the multiple words corresponding to the event text.

[0094] Step 112: Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain a vector corresponding to the event text.

[0095] Step 113: Use the event text classifier to process the vector corresponding to the event text to obtain a set of text names related to the event text.

[0096] Step 114: Filter out a preset number of text names from the text name set, and obtain the clause corresponding to each text name to obtain a candidate clause set.

[0097] In the above process, the vector corresponding to the aggregated event text is then processed by the event text classifier, which can prioritize which text names in the text names to which the event text belongs, and quickly obtain a set of candidate clauses based on the determined text names.

[0098] The event text classifier processes the vector corresponding to the event text and can determine the text name that matches the event text description from all the text names in the database. For example, the event text classifier can process the description of the case text and select the three laws that best match the case text description from a large number of legal names. Finally, based on the legal name, all the corresponding legal articles are selected as the candidate legal article set. The legal name can be selected using the following formula:

[0099] y law =σ(W law E a +b law ).

[0100] Among them E a Represents the overall vector of event text, W law ,b law is the trainable parameter of the legal classifier, σ represents the sigmoid function as a nonlinear activation function, and y law Indicates the probability of the event text being related to the clause. The greater the probability, the more consistent it is with the description of the case text.

[0101] The vectors of each word in the multiple words corresponding to the event text are aggregated to obtain the vector corresponding to the event text through the following formula:

[0102] α i =q t tanh(V t ×h i +v t ).

[0103] E a =∑α i h i .

[0104] where q t is a trainable parameter, V t and v tis a trainable parameter, i represents the i-th word, h i Represents the vector of the i-th word, a represents the weight, a i is the weight of the i-th word, and the context vectors of all words are weighted and summed to get the vector representation of the entire text. Tanh represents the hyperbolic tangent function, and E a A vector representing the event text.

[0105] According to the calculation method of the event text vector, the event text classifier is used to process the vector corresponding to the event text, and the text name set related to the event text can be obtained by the following formula:

[0106] y law =FFN(E a ).

[0107] Among them, FFN is a fully connected neural network, a represents the weight, E a Represents the vector corresponding to the event text, y law Indicates the probability that the text name and event text are related. The greater the probability, the higher the correlation.

[0108] In addition, the vector corresponding to the event text can be obtained by Figure 2 Obtained by the method in .

[0109] Please see Figure 2 , Figure 2 A schematic diagram of a method for obtaining a vector corresponding to an event text is shown in FIG. Figure 2 The methods shown include:

[0110] Among them, w1, w2, w3, w4 represent different event texts, a represents the weight, Σ represents the aggregation of h1, h2, h3 and h4, and the event text is encoded by the self-attention encoder to obtain the vector (h1, h2, h3, h4) of each of the multiple words corresponding to the event text. The vectors in the event text are aggregated using the function and according to the weight of the vector of each word to obtain the text vector corresponding to the event text.

[0111] Specifically, when executing step 110, the following steps may be performed:

[0112] Step 1101: Perform matching on the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set, and obtain the matching score of the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set.

[0113] Step 1102: After each article in the candidate article set undergoes step 1103, a fine-grained matching score between each article in the candidate article set and the event text is obtained.

[0114] Step 1103: Sum the scores of the vectors of each of the multiple words corresponding to the event text and the vectors of all words in the Nth article in the candidate article set with the highest matching score to obtain the matching score between the event text and the Nth article, where N is a positive integer greater than or equal to 1.

[0115] In the above process, the sum of the scores corresponding to each of the multiple words in the event text and the Nth article is used as the fine-grained score of the event text and the article. The fine-grained matching score between each article in the candidate article set and the event text obtained by this method is more representative, making the final recommended article result more accurate.

[0116] The vectors of each word in the event text and the article are matched, and a maximum pooling method is used to obtain a fine-grained matching score between the vectors of each word in the multiple words corresponding to the event text and the vectors of all words in each article in the candidate article set. The specific calculation results can be obtained using the following formula:

[0117]

[0118] Sim2=∑S i .

[0119] Among them, a represents the weight, i represents the i-th word, S i Indicates the matching score between the vector of the i-th word in the event text and an article, Represents the matrix of word vectors, max represents the maximum value, and Sim2 represents the matching score between the event text and an article.

[0120] For the above description, please refer to Figure 3 , Figure 3 A schematic diagram of a method for article recommendation based on fine-grained text matching provided in this application, such as Figure 3 The methods recommended by the provisions shown include:

[0121] The event text and the set of candidate articles are input into the self-attention text encoder to obtain the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set. Then, through fine-grained text matching of the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set, the fine-grained matching score between each article and the event text is obtained. Finally, the article recommendation is completed based on the fine-grained matching score.

[0122] Step 120: Perform matching on the vector corresponding to the event text and the vector of each article in the candidate article set to obtain a coarse-grained matching score between each article and the event text.

[0123] In the above process, the coarse-grained matching score between each article and the event text can be obtained based on the vector corresponding to the event text and the vector of each article in the candidate article set, providing a screening factor for the final recommended article.

[0124] Among them, the matching degree is performed based on the vector corresponding to the event text and the vector of each article in the candidate article set, and the coarse-grained matching score of each article and the event text is obtained by dot product. Specifically, the coarse-grained matching score of each article and the event text can be obtained by the following formula:

[0125] E f ={E f1 ,E f2 ,…,E fn}.

[0126] E fw ={E w1 ,E w2 ,…,E wn}.

[0127]

[0128] Among them, E a Represents the event text vector, E f The set of vectors representing clauses, E fn The vector representing the nth clause, E fw represents the set of vectors of f words in the wth article, E wn represents the vector of the nth word in the wth article, T is the matrix transpose, and Sim1 represents the coarse-grained matching score between an article and the event text obtained by dot product.

[0129] Specifically, before executing step 120, the following steps may be performed:

[0130] Step 1201: Use the pre-trained self-attention text encoder to encode the event text and each article in the candidate article set to obtain the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set.

[0131] Step 1202: Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain the vector corresponding to the event text.

[0132] Step 1203: Aggregate the vectors of all words in each article in the candidate article set to obtain the vector of each article in the candidate article set.

[0133] In the above process, the self-attention text encoder obtained through continuous training is used to obtain the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set, and the vectors corresponding to the event text and the vectors of each article in the candidate article set are aggregated separately, which have higher accuracy.

[0134] Among them, the vectors of each of the multiple words corresponding to the event text are aggregated to obtain the vector corresponding to the event text. The event text and the article are encoded separately through the self-attention text encoder, and the context vectors of the obtained words are aggregated to obtain the vector representation corresponding to the event text and stored.

[0135] After step 120, specifically, based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text, a preset number of recommended articles are determined from the candidate article set, including:

[0136] Step 121: weighted sum of the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text to obtain a total matching score corresponding to each article in the candidate article set.

[0137] Step 122: Determine a preset number of recommended articles from the candidate article set based on the total matching score corresponding to each article in the candidate article set.

[0138] In the above process, the articles are screened by the coarse-grained matching score between each article and the event text, and the fine-grained matching scores of all articles in the candidate article set and the event text are weighted summed. The articles are screened based on the total score after the weighted summation, so that the final recommendation results are more accurate.

[0139] The preset number of clauses can be set according to user needs. In addition, the fine-grained matching scores of all clauses in the candidate clause set and the event text and the coarse-grained matching scores of all clauses in the candidate clause set and the event text are weighted and summed to obtain the total matching score corresponding to each clause in the candidate clause set. This is calculated using the following formula:

[0140] Sim=λ1Sim1+λ2Sim2.

[0141] Among them, λ1 and λ2 are hyperparameters, Sim represents the total matching score between an article and the event text, Sim1 represents the coarse-grained matching score between the article and the event text, and Sim2 represents the matching score between the event text and the article.

[0142] The following takes one of the articles and one event text as an example to describe the total matching score between the event text and the article text.

[0143] Please see Figure 4 , Figure 4 A schematic diagram of a method for obtaining the total matching score of event text and article text provided in this application, such as Figure 4 The method includes:

[0144] Among them, h1, h2, h3, h4 are the vectors of the words in the article, h5, h6, h7, h8 are the vectors of the words in the event, S1, S2, S3, S4 are the matching scores between the words of each event and the article, T1 is the vector corresponding to the event text, and T2 is the vector of the article text. First, the vector of each word in the event text and the vector of each word in the article are fine-grained matched, and the score S1 with the highest matching score of h5 and h1, h2, h3, h4 is taken as the score of h5 with the article. Matching score: take the highest matching score S2 of h6 and h1, h2, h3, and h4 as the matching score of h6 and the article; take the highest matching score S1 of h7 and h1, h2, h3, and h4 as the matching score of h7 and the article; take the highest matching score S4 of h8 and h1, h2, h3, and h4 as the matching score of h8 and the article. The sum Sim2 of S1, S2, S3, and S4 is the fine-grained matching score of the article and the event text. Secondly, the vector corresponding to the event text and the vector of the article text are dot-producted to obtain the coarse-grained matching score Sim1 of the article and the event text. Finally, the weighted sum of Sim1 and Sim2 is used to obtain the total matching score Sim of the event text and the article text.

[0145] In addition, step 110 can be used in the model. By training the model, the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set are input into the model, and the fine-grained matching score of each article and the event text can be directly obtained, and then the articles can be screened according to the score. Among them, through the records in the database, the triple training data set and test set of (event text, text name, article content) are obtained to train and test the model to obtain the model. In the process of obtaining the data, the Chinese word segmentation tool is also used to pre-process the data to obtain the training data format that can be input into the model.

[0146] Step 130: Determine a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text.

[0147] In the above process, through a more fine-grained matching mechanism and scoring the matching results, the solution of this application can achieve the effect of accurately and efficiently recommending clauses.

[0148] Specifically, when executing step 120, the following steps may be performed:

[0149] Based on the fine-grained matching scores of all articles in the candidate article set and the event text, each article in the candidate article set is sorted from high score to low score to obtain a sorted queue, and a preset number of recommended articles are determined starting from the first one in the queue.

[0150] In the above process, the articles are sorted according to the scores, and a certain number of the first few articles are taken as the final recommendation results. The selected articles are more consistent with the description of the event text.

[0151] Previous article passed Figure 1-Figure 4 Describes the method recommended by the article, combined with Figure 5-Figure 6 Describe the device recommended by the article.

[0152] Please refer to Figure 5 , is a schematic block diagram of a device 500 for recommending a clause provided in an embodiment of the present application. The device 500 may be a module, program segment or code on an electronic device. The device 500 is similar to the above Figure 1 The method embodiment corresponds to the embodiment that can be executed Figure 1 The various steps involved in the method embodiment and the specific functions of the device 500 can be found in the description below. To avoid repetition, detailed description is appropriately omitted here.

[0153] Optionally, the device 500 includes:

[0154] Matching module 510, for matching the vector of each word in the multiple words corresponding to the event text with the vectors of all words in each article in the candidate article set, to obtain a fine-grained matching score between each article and the event text;

[0155] The second matching module 520 is used to perform matching between the vector corresponding to the event text and the vector of each article in the candidate article set, and obtain a coarse-grained matching score between each article and the event text;

[0156] The recommendation module 530 is used to determine a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text.

[0157] Optionally, the recommendation module is specifically used to:

[0158] The fine-grained matching scores of all clauses in the candidate clause set and the event text and the coarse-grained matching scores of all clauses in the candidate clause set and the event text are weighted and summed to obtain the total matching score corresponding to each clause in the candidate clause set;

[0159] A preset number of recommended articles are determined from the candidate article set based on the total matching score corresponding to each article in the candidate article set.

[0160] Optionally, the device further includes:

[0161] an aggregation module for performing, before the second matching module performs degree matching on the vector corresponding to the event text and the vector of each article in the candidate article set to obtain a coarse-grained matching score between each article and the event text, an aggregation module for encoding the event text and each article in the candidate article set using a pre-trained self-attention text encoder to obtain a vector for each of the multiple words corresponding to the event text and a vector for all words in each article in the candidate article set;

[0162] Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain the vector corresponding to the event text;

[0163] The vectors of all words in each article in the candidate article set are aggregated separately to obtain the vector of each article in the candidate article set.

[0164] Optionally, the device further includes:

[0165] The encoding module is used for the matching module to use a pre-trained self-attention text encoder to encode the event text and each article in the candidate article set before matching the vector of each word in the multiple words corresponding to the event text with the vectors of all words in each article in the candidate article set to obtain the fine-grained matching score of each article with the event text, thereby obtaining the vector of each word in the multiple words corresponding to the event text and the vectors of all words in each article in the candidate article set.

[0166] Optionally, the device further includes:

[0167] An acquisition module is configured to encode the event text using a pre-trained self-attention text encoder to obtain a vector for each of the multiple words corresponding to the event text, before the matching module performs degree matching on the vectors of each word in the multiple words corresponding to the event text and the vectors of all words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text;

[0168] Aggregate the vectors of each word in the multiple words corresponding to the event text to obtain the vector corresponding to the event text;

[0169] Use the event text classifier to process the vector corresponding to the event text to obtain a set of text names related to the event text;

[0170] A preset number of text names are filtered out from the text name set, and the clause corresponding to each text name is obtained to obtain a candidate clause set.

[0171] Optionally, the matching module is specifically configured to:

[0172] Perform matching on the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set, and obtain a matching score for the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set;

[0173] Each clause in the candidate clause set undergoes the following steps to obtain a fine-grained matching score between each clause in the candidate clause set and the event text:

[0174] The vector of each of the multiple words corresponding to the event text and the vector of all words in the Nth article in the candidate article set with the highest matching score are summed to obtain the matching score between the event text and the Nth article, where N is a positive integer greater than or equal to 1.

[0175] Optionally, the recommendation module is specifically used to:

[0176] Based on the fine-grained matching scores of all articles in the candidate article set and the event text, each article in the candidate article set is sorted from high score to low score to obtain a sorted queue, and a preset number of recommended articles are determined starting from the first one in the queue.

[0177] Please refer to Figure 6 This is a schematic block diagram of the structure of a device 600 for recommending a clause provided in an embodiment of the present application. The device may include a memory 610 and a processor 620. Optionally, the device may also include: a communication interface 630 and a communication bus 640. The device is similar to the above Figure 1The method embodiment corresponds to the embodiment that can be executed Figure 1 The various steps involved in the method embodiment and the specific functions of the device can be found in the description below.

[0178] Specifically, the memory 610 is used to store computer-readable instructions.

[0179] Processor 620 is used to process the readable instructions stored in the memory and can execute Figure 1 Each step of method embodiments 110 to 130.

[0180] The communication interface 630 is used for signaling or data communication with other node devices, for example, for communication with a server or terminal, or for communication with other device nodes, but the present invention is not limited thereto.

[0181] The communication bus 640 is used to realize direct connection and communication among the above components.

[0182] Among them, the communication interface 630 of the device in the embodiment of the present application is used to communicate signaling or data with other node devices. The memory 610 can be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 610 can also be at least one storage device located away from the aforementioned processor. The memory 610 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 620, the electronic device executes the above-mentioned Figure 1 The method process shown. The processor 620 can be used on the device 500 and is used to perform the functions in the present application. Exemplarily, the above-mentioned processor 620 can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and the embodiments of the present application are not limited thereto.

[0183] The embodiment of the present application further provides a readable storage medium, wherein when the computer program is executed by a processor, Figure 1 The method process in the illustrated method embodiment is performed by the electronic device.

[0184] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working process of the device described above can refer to the corresponding process in the aforementioned method, and will not be described in detail here.

[0185] In summary, the embodiments of the present application provide a method, device, electronic device and readable storage medium for article recommendation, the method comprising: performing degree matching on the vector of each of the multiple words corresponding to the event text and the vectors of all the words of each article in the candidate article set, respectively, to obtain a fine-grained matching score between each article and the event text; performing degree matching on the vector corresponding to the event text and the vector of each article in the candidate article set, respectively, to obtain a coarse-grained matching score between each article and the event text; and determining a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set and the event text and the coarse-grained matching scores of each article and the event text. This method can achieve the effect of accurately and efficiently recommending articles.

[0186] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or can be implemented using a combination of dedicated hardware and computer instructions.

[0187] In addition, the functional modules in each embodiment of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0188] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0189] The foregoing is merely an embodiment of the present application and is not intended to limit the scope of protection of the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included within the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following figures. Therefore, once an item is defined in one figure, it does not need to be further defined or explained in subsequent figures.

[0190] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

[0191] 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 the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so 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 other identical elements in the process, method, article, or device comprising the element.

Claims

1. A method for recommending an article, characterized in that: include: Perform matching on the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set, and obtain a fine-grained matching score between each article and the event text; The method for calculating the fine-grained matching score between each article and the event text is as follows: the vector of each word in the event text is fine-grainedly matched with the vector of each word in the article, the highest score of the vector matching of each word is taken as the matching score of the article, and the matching scores of multiple words corresponding to the event text are summed to obtain the fine-grained matching score between the article and the event text; Performing matching on the vector corresponding to the event text and the vector of each article in the candidate article set, respectively, to obtain a coarse-grained matching score between each article and the event text; The method for calculating the coarse-grained matching score between each article and the event text is to obtain the coarse-grained matching score between the article and the event text by the dot product of the vector corresponding to the event text and the vector of the article text; Determining a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text; The vector of each of the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set are calculated according to the importance of the words at different positions in the text using the following formula: t represents the position of the word in the text, d is the dimension of the word vector, and timing (t,i) The value of the importance of the i-th position in the word vector representing the position of the t-th word; The method of matching the vectors of each of the multiple words corresponding to the event text with the vectors of all the words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text includes: inputting the vectors of each of the multiple words corresponding to the event text and the vectors of all the words in each article in the candidate article set into the model to obtain a fine-grained matching score between each article and the event text, wherein the model is obtained by training and testing a triple training data set and a test set recorded in a database, and the triple training data set and the test set include event text, text name and article content.

2. The method according to claim 1, characterized in that The step of determining a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text comprises: The fine-grained matching scores of all clauses in the candidate clause set and the event text and the coarse-grained matching scores of all clauses in the candidate clause set and the event text are weighted and summed to obtain a total matching score corresponding to each clause in the candidate clause set; The preset number of recommended articles are determined from the candidate article set based on the total matching score corresponding to each article in the candidate article set.

3. The method according to claim 1 or 2, characterized in that Before respectively matching the vector corresponding to the event text with the vector of each article in the candidate article set to obtain a coarse-grained matching score between each article and the event text, the method further includes: Encode the event text and each article in the candidate article set using a pre-trained self-attention text encoder to obtain a vector for each of the multiple words corresponding to the event text and a vector for all words in each article in the candidate article set; Aggregating the vectors of each of the multiple words corresponding to the event text to obtain a vector corresponding to the event text; The vectors of all words in each article in the candidate article set are aggregated separately to obtain the vector of each article in the candidate article set.

4. The method according to claim 1 or 2, characterized in that Before respectively matching the vector of each word in the plurality of words corresponding to the event text with the vectors of all words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text, the method further includes: The event text and each article in the candidate article set are encoded using a pre-trained self-attention text encoder to obtain the vector of each word in the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set.

5. The method according to claim 1 or 2, characterized in that Before respectively matching the vector of each word in the plurality of words corresponding to the event text with the vectors of all words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text, the method further includes: Encode the event text using a pre-trained self-attention text encoder to obtain a vector for each of the multiple words corresponding to the event text; Aggregating the vectors of each of the multiple words corresponding to the event text to obtain a vector corresponding to the event text; Using an event text classifier to process the vector corresponding to the event text to obtain a set of text names related to the event text; A preset number of text names are screened out from the text name set, and the clause corresponding to each text name is obtained to obtain the candidate clause set.

6. The method according to claim 1 or 2, characterized in that The vector of each word in the multiple words corresponding to the event text is matched with the vectors of all words in each article in the candidate article set to obtain a fine-grained matching score between each article and the event text, including: Performing matching on the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set, respectively, to obtain a matching score for the vector of each of the multiple words corresponding to the event text and the vector of all the words in each article in the candidate article set; Each clause in the candidate clause set undergoes the following steps to obtain a fine-grained matching score between each clause in the candidate clause set and the event text: The vector of each of the multiple words corresponding to the event text and the corresponding scores of the vectors of all words in the Nth article in the candidate article set with the highest matching score are summed to obtain the matching score between the event text and the Nth article, where N is a positive integer greater than or equal to 1.

7. The method according to claim 1 or 2, characterized in that The step of determining a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text comprises: Based on the fine-grained matching scores of all articles in the candidate article set and the event text, each article in the candidate article set is sorted from high score to low score to obtain a sorted queue, and the preset number of recommended articles are determined starting from the first one in the queue.

8. A device for recommending articles, characterized in that: include: A matching module is used to match the vector of each word in the multiple words corresponding to the event text with the vectors of all words in each article in the candidate article set, and obtain a fine-grained matching score between each article and the event text; A second matching module is used to perform matching on the vector corresponding to the event text and the vector of each article in the candidate article set, and obtain a coarse-grained matching score between each article and the event text; A recommendation module, configured to determine a preset number of recommended articles from the candidate article set based on the fine-grained matching scores of all articles in the candidate article set with the event text and the coarse-grained matching scores of all articles in the candidate article set with the event text; The vector of each of the multiple words corresponding to the event text and the vector of all words in each article in the candidate article set are calculated according to the importance of the words at different positions in the text using the following formula: t represents the position of the word in the text, d is the dimension of the word vector, and timing (t,i) The value of the importance of the i-th position in the word vector representing the position of the t-th word; The matching module is specifically used to: input the vector of each word in the multiple words corresponding to the event text and the vectors of all words in each article in the candidate article set into the model to obtain a fine-grained matching score between each article and the event text, wherein the model is obtained by training and testing the triple training data set and test set recorded in the database, and the triple training data set and test set include event text, text name and article content.

9. A device recommended by the article, characterized in that include: A memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the steps of the method according to any one of claims 1 to 7 are executed.

10. A computer-readable storage medium, characterized in that include: A computer program, when running on a computer, causes the computer to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Reusable law article recommendation framework

    CN110717843A

  • Text similarity calculation system and method based on multi-keyword pair matching, and storage medium

    CN112232053A