Article recommendation model training method, article recommendation method, electronic device and product

By training user characteristics, article statistical features and article word vectors in the dataset, the article recommendation model is trained, which solves the problem of difficult to understand article complexity and diversity in the existing technology, and achieves a more accurate article recommendation effect.

CN119782606APending Publication Date: 2025-04-08SHANGHAI DOUXIANG INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411802178.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-09
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

The existing article recommendation system is difficult to deeply understand the complexity and diversity of the article content, cannot fully reflect the rich connotation of the article, and is difficult to accurately grasp the overall semantics of the article.

Method used

By obtaining the training data set, including user features, article statistical features and article word vectors, the initial article recommendation model is trained based on these data to obtain a trained article recommendation model. The model combines user characteristics and article characteristics to more accurately reflect the complexity and diversity of article content and improves the accuracy of recommendation results.

Benefits of technology

It can more accurately reflect the complexity and diversity of article content, improve the accuracy of recommendation results, and better meet the actual needs of users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119782606A_ABST
    Figure CN119782606A_ABST
Patent Text Reader

Abstract

The present application provides an article recommendation model training method, an article recommendation method, an electronic device and a product, and relates to the technical field of article recommendation. An article recommendation model training method, comprising: obtaining a training data set, the training data set comprising a plurality of training data, each training data comprising user features, article statistical features and article word vectors corresponding to a specified article, and article statistical features and article word vectors corresponding to an article to be recommended, and each training data is annotated with a label representing whether it is recommended; training an initial article recommendation model based on the training data set to obtain a trained article recommendation model. Since the article word vector can reflect the content characteristics of the article itself, it can more accurately reflect the complexity and diversity of the article content and reflect the connotation of the article itself. Combining the article word vector of the target article and the article word vector of the article to be recommended can make the final recommendation result closer to the target article.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of article recommendation, and specifically, to an article recommendation model training method, an article recommendation method, an electronic device and a product. Background Art

[0002] Current article recommendation systems are usually implemented in the following three ways.

[0003] The first method relies on user behavior data and traditional machine learning models to generate recommendation information. Although this method can capture the user's direct preferences, it ignores the deep semantic information of the article content. For example, through user behavior data such as clicks, browsing, and dwell time, the system can infer the user's short-term interests, but it is difficult to deeply understand the complexity and diversity of the article content.

[0004] The second method is to use a tag-based recommendation method to classify and recommend content by assigning keyword tags to articles. However, this method is based on simple word segmentation and statistical techniques, which makes it difficult to capture the subtle semantic differences and deep connections between articles. Moreover, the tag system cannot fully reflect the rich connotations of the article.

[0005] The third method is to use word embedding technologies such as word2vec (a related model used to generate word vectors) to convert text into vector representation, in order to recommend related content through similarity in the vector space. However, technologies such as word2vec lack in-depth understanding of long texts and complex contexts, making it difficult to accurately grasp the overall semantics of the article. Summary of the invention

[0006] The present application provides an article recommendation model training method, an article recommendation method, an electronic device and a product to solve at least one of the following problems: the existing article recommendation system has difficulty in deeply understanding the complexity and diversity of the article content, cannot fully reflect the rich connotation of the article, and has difficulty in accurately grasping the overall semantics of the article.

[0007] In a first aspect, the present application provides an article recommendation model training method, comprising: obtaining a training data set, the training data set comprising multiple training data, each training data comprising user features, article statistical features and article word vectors corresponding to a specified article, and article statistical features and article word vectors corresponding to an article to be recommended, and each training data is annotated with a label indicating whether it is recommended; training an initial article recommendation model based on the training data set to obtain a trained article recommendation model.

[0008] In the embodiment of the present application, the article word vector can reflect the content characteristics of the article itself, so as to more accurately reflect the complexity and diversity of the article content and reflect the connotation of the article itself. The article word vector of the combined target article and the article word vector of the article to be recommended can make the final recommendation result closer to the target article. At the same time, since user characteristics can reflect the user's own preferences, the determined recommended articles also take into account the user's own preferences. In addition, the statistical characteristics of the article reflect other characteristics besides the content of the article itself. Combined with user characteristics, it can further reflect the user's preferences in more aspects, and further improve the similarity between the recommended article and the target article, so that the recommendation effect of the article recommendation model obtained by training including user characteristics, article statistical characteristics corresponding to the specified article and article word vectors is better.

[0009] In combination with the technical solution provided in the first aspect above, in some possible implementations, the designated article is an article that the user clicks to read on a designated website, and the articles to be recommended are several articles recommended to the user by the designated website when the user clicks to read the designated article.

[0010] In combination with the technical solution provided in the first aspect above, in some possible implementations, obtaining a training data set includes: obtaining a user's browsing history on a specified website; based on the browsing history, marking the recommended articles clicked by the user while reading the specified article with a label representing recommendation, and marking the recommended articles not clicked by the user with a label representing non-recommendation.

[0011] In an embodiment of the present application, whether to recommend a tag is determined by the user's actual browsing history, so that the obtained training data set can be more in line with the user's actual situation, and then the article recommendation performed by the article recommendation model trained using the training data set can be more in line with the user's actual needs.

[0012] In combination with the technical solution provided in the first aspect above, in some possible implementations, it also includes: obtaining knowledge information in the field where the specified article is located, and preprocessing the knowledge information to form a knowledge base; using the knowledge base to pre-train an initial feature extraction model to obtain a feature extraction model; and obtaining the article word vector corresponding to the specified article and the article word vector corresponding to the article to be recommended through the feature extraction model.

[0013] In the embodiment of the present application, since the feature extraction model is pre-trained by constructing a knowledge base based on the knowledge information of the field in which the specified article is located, the features extracted by the feature extraction model can more accurately reflect the characteristics of the field, thereby enabling more accurate article recommendations to be made based on the article word vectors.

[0014] In combination with the technical solution provided in the first aspect above, in some possible implementations, the designated article and the article to be recommended are both articles in the field of network security; accordingly, the user characteristics include user behavior characteristics and user network security portrait characteristics; wherein the user behavior characteristics characterize the characteristics of the user's operations on the article; and the user network security portrait characteristics reflect the user's knowledge structure characteristics in the field of network security.

[0015] In the embodiment of the present application, since the user's network security portrait characteristics can reflect the user's knowledge level in the field of network security, the user characteristics including the user's network security portrait characteristics and the user behavior characteristics are used as reference data for article recommendation, so that the final recommended article can be in line with the user's knowledge level and improve the user experience.

[0016] In a second aspect, the present application provides an article recommendation method, comprising: obtaining user characteristics of a designated user, article statistical characteristics and article word vectors corresponding to several articles to be recommended, and article statistical characteristics and article word vectors corresponding to a target article; based on the article statistical characteristics and article word vectors corresponding to several articles to be recommended, the article statistical characteristics and article word vectors corresponding to the target article, and the user characteristics, using a pre-trained article recommendation model, obtaining recommendation scores corresponding to several articles to be recommended; based on the obtained recommendation scores corresponding to the several articles to be recommended, determining recommended articles and recommending them to the designated user.

[0017] In the embodiment of the present application, the article word vector can reflect the content characteristics of the article itself, so as to more accurately reflect the complexity and diversity of the article content and reflect the connotation of the article itself. The article word vector of the combined target article and the article word vector of the article to be recommended can make the final recommendation result closer to the target article. At the same time, since the user characteristics can reflect the user's own preferences, the determined recommended articles also take into account the user's own preferences. In addition, the statistical characteristics of the article reflect other characteristics besides the content of the article itself. Combined with the user characteristics, it can further reflect the user's preferences in more aspects, and further improve the similarity between the recommended article and the target article, so that the recommendation results can be more accurate.

[0018] In combination with the technical solution provided in the second aspect above, in some possible implementations, it also includes: using a pre-trained feature extraction model to obtain the article word vector corresponding to the target article and the article word vectors corresponding to several of the articles to be recommended, and storing them in a database; before using the article recommendation model to obtain the recommendation scores of several of the articles to be recommended, obtaining the article word vector corresponding to the target article and the article word vectors corresponding to several of the articles to be recommended from the database.

[0019] In combination with the technical solution provided in the second aspect above, in some possible implementations, the article to be recommended and the target article are both articles in the field of network security.

[0020] In a third aspect, the present application provides an electronic device, comprising: a memory and a processor, the memory and the processor being connected; the memory being used to store programs; the processor being used to call the programs stored in the memory to execute the method described in the first aspect above and / or in combination with any possible implementation of the first aspect above, or to execute the method described in the second aspect above and / or in combination with any possible implementation of the second aspect above.

[0021] In a fourth aspect, the present application provides a computer program product, comprising a computer program, wherein the computer program is executed by a processor according to the first aspect and / or the method described in any possible embodiment of the first aspect, or the second aspect and / or the method described in any possible embodiment of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. 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 related drawings can be obtained based on these drawings without paying creative work.

[0023] Figure 1 A flowchart of an article recommendation model training method shown in an embodiment of the present application;

[0024] Figure 2 A logical schematic diagram of an article recommendation model training method shown in an embodiment of the present application;

[0025] Figure 3 A flowchart of an article recommendation method shown in an embodiment of the present application;

[0026] Figure 4 A structural block diagram of an electronic device shown in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0028] It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it is not necessary to further define and explain it in the subsequent drawings. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements that are not clearly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements limited by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements.

[0029] The technical solution of the present application will be described in detail below with reference to the accompanying drawings.

[0030] See also Figure 1 , Figure 1 This is a method for training an article recommendation model shown in the embodiment of the present application. Figure 1 Describe the steps it involves.

[0031] S100: Obtain a training data set.

[0032] The training data set includes multiple training data, each of which includes user features, article statistical features and article word vectors corresponding to a specified article, and article statistical features and article word vectors corresponding to the article to be recommended, and each training data is annotated with a label indicating whether it is recommended.

[0033] In one implementation manner, the designated article may be an article in a preset article database, and the article to be recommended may be any article among the remaining articles in the article database.

[0034] Alternatively, historical data of users may be collected, and training data may be filtered out based on the historical data.

[0035] Optionally, the designated article may be an article that the user clicks to read on a designated website, and the articles to be recommended may be a number of articles that the designated website recommends to the user when the user clicks to read the designated article.

[0036] In this implementation, the specific method of obtaining the training data set may be: first, obtain the browsing history of the user on the specified website. According to the browsing history, the recommended articles clicked by the user in the process of reading the specified article are marked with a label indicating recommendation, and the recommended articles not clicked by the user are marked with a label indicating non-recommendation.

[0037] For example, when a user is reading a specified article, 10 articles will be recommended to the user. If the user clicks on a recommended article, the article clicked by the user and the article statistical features and article word vectors corresponding to the recommended article clicked by the user, as well as the user features are marked as recommended labels to obtain a piece of training data.

[0038] The recommended articles that the user did not click, the article statistical features and article word vectors corresponding to the articles, and the user features are marked as not recommended labels to obtain a piece of training data.

[0039] The examples given here are only for ease of understanding and should not be construed as limiting the present application.

[0040] In one implementation, the word vector of the article can be obtained based on a pre-set word vector model.

[0041] In one implementation, the word vector of the article can also be obtained by inputting the article into a pre-trained feature extraction model to obtain the word vector corresponding to the input article.

[0042] Optionally, the knowledge information of the field in which the specified article is located can be obtained first, and the knowledge information can be preprocessed to form a knowledge base. Then, the initial feature extraction model can be pretrained using the knowledge base to obtain a feature extraction model. Finally, the article word vector corresponding to the specified article and the article word vector corresponding to the article to be recommended can be obtained through the feature extraction model.

[0043] Alternatively, the feature extraction model can also be pre-trained and can be used directly when needed.

[0044] Optionally, before inputting the article (article to be recommended, designated article) into the pre-trained feature extraction model to obtain the corresponding article word vector, the article can be pre-processed. The pre-processing includes at least one of noise removal, stop word filtering, word segmentation and part-of-speech tagging. After that, the pre-processed article is input into the pre-trained feature extraction model to obtain the corresponding article word vector.

[0045] Among them, the specific methods and principles of noise removal, stop word filtering, word segmentation and part-of-speech tagging are well known to those skilled in the art and will not be repeated here for the sake of brief description.

[0046] Optionally, the specific training process of the feature extraction model may be: first, a target vocabulary is obtained, the target vocabulary includes multiple word segments and a vector corresponding to each word segment, and then a preset pre-trained model is pre-trained based on the target vocabulary to obtain a feature extraction model.

[0047] Optionally, you can configure the environment before training the model.

[0048] For example, when training models in a GPU (Graphics Processing Unit) environment, you need to prepare an appropriate GPU environment. You can use a high-performance GPU server and configure the corresponding GPU acceleration libraries such as CUDA (Compute Unified Device Architecture) and cuDNN (Deep Neural Network Library) to ensure the efficiency and speed of model training.

[0049] Optionally, multiple preset pre-trained models may be pre-trained to obtain multiple trained feature extraction models to be selected. The multiple feature extraction models to be selected are then tested using a test data set, and the feature extraction model to be selected with the best performance is selected as the final feature extraction model.

[0050] The performance of the feature extraction model to be selected can be evaluated by indicators such as accuracy, recall, F1 score (an indicator used in statistics to measure the accuracy of a binary classification model) and mean average precision (MAP).

[0051] In one implementation, the target vocabulary may be pre-acquired and can be directly called when needed.

[0052] Alternatively, the target vocabulary may be obtained by first obtaining a target database, which includes multiple articles, then preprocessing all articles in the target database, and generating a target vocabulary based on the preprocessed target database; wherein the preprocessing includes stop word filtering, word segmentation, and part-of-speech tagging.

[0053] For example, you can use the Sentence Piece tool (an unsupervised text tokenizer and de-tokenizer) to generate a vocabulary to convert text data into the input form of the feature extraction model. Then generate a file in the tf_records format (a binary file format), that is, convert the original text data into the tf_records format for the convenience of the feature extraction model and processing. Then pre-train, specifically use the generated tf_records format data to pre-train the XLNet model (a pre-trained model) to adjust the parameters of the feature extraction model. Monitor the performance and convergence of the model during the pre-training process. Then define appropriate training parameters, such as learning rate, batch size, number of training rounds, and early stopping strategy. Finally, monitor the training process and record the loss function value and evaluation indicators to adjust the parameters and avoid overfitting.

[0054] Optionally, the feature extraction model may be a model such as an XLNet pre-trained model.

[0055] For example, the feature extraction model can be any of the two XLNet pre-trained models: XLNet-mid: 24-layer, 768-hidden, 12-heads, 209Mparameters; XLNet-base: 12-layer, 768-hidden, 12-heads, 117Mparameters. XLNet-mid and XLNet-base are suitable for different computing resources and performance requirements. If you are more concerned about the accuracy of the model and do not care about the model performance and hardware, you can choose the XLNet-mid model.

[0056] In one implementation mode, the designated article and the article to be recommended are both articles in the field of network security.

[0057] Optionally, when both the designated article and the article to be recommended are articles in the field of network security, the user features may include user behavior features and user network security portrait features. The user behavior features characterize the characteristics of the user's operation on the article; the user network security portrait features reflect the user's knowledge structure characteristics in the field of network security.

[0058] Optionally, when both the designated article and the article to be recommended are articles in the field of network security, the knowledge information in the field of the designated article may include: articles in the field of network security, threat intelligence library, vulnerabilities, red-blue team confrontation attack and defense knowledge and other related professional knowledge, code and network protocol knowledge, Chinese wiki and general data.

[0059] Articles in the field of cybersecurity may include articles such as Freebuf (a cybersecurity industry portal), CVE (Common Vulnerabilities & Exposures) database, security white papers and vulnerability reports.

[0060] The threat intelligence library specifically refers to a knowledge base that integrates the latest threat intelligence data and will update and enrich the article recommendation system in real time.

[0061] Relevant professional knowledge such as vulnerabilities, red-blue team confrontation attack and defense knowledge include the following: CVE (Common Vulnerabilities and Exposures) Database, National Vulnerability Database (NVD, a comprehensive vulnerability database maintained by the National Institute of Standards and Technology of the United States), Exploit Database (Global Vulnerability Database), Malware Sample Data Sets (a public, continuously updated malware database), Drebin Android Malware Dataset (a dataset containing 5,560 applications), IoT Attack Datasets, GitHub Security Labs (various security-related datasets and tools provided by GitHub Security Labs).

[0062] Code and network protocol knowledge refers to obtaining codes of various computer languages ​​and descriptions and real traffic of various network protocols through GitHub (a hosting platform for open source and private software projects). Specific protocols include HTTP(S) (HyperText Transfer Protocol), IMAP (Internet Mail Access Protocol), SSL / TLS (Secure Sockets Layer / Transport Layer Security), SMTP (Simple Mail Transfer Protocol), FTP (File Transfer Protocol), SSH (Secure Shell) and other related protocols.

[0063] Chinese Wikipedia and general data (encyclopedia, news, Q&A, etc.).

[0064] In one implementation mode, the user behavior characteristics include at least one of the average reading time of the user for similar articles, the time the user spends on each article, the number of similar articles read by the user, the number of similar articles read by the user in the past month, the number of times the user clicks on each type of article, the proportion of clicks on a certain type of article to the total number of clicks, the average stay time of the user on each article, the distribution of the user's stay time on different types of articles, the total stay time of the user on the entire website, the number of times the user likes different types of articles, the number of times the user comments on different types of articles, the number of times the user shares different types of articles, the number of times the user collects articles, the category distribution of the user's collected articles, the keywords searched by the user, and the number of times the user clicks on different types of articles in the search results; wherein the similar articles are articles of the same category as the target article.

[0065] The keywords searched by the user may be vectorized by all keywords searched by the user in the past, or may be counted by the number of keywords searched by each user.

[0066] In one implementation mode, the user's network security portrait features include at least one of user tags, user security field level, number of vulnerabilities submitted by the user, number of malicious files submitted by the user, number of network security courses attended by the user, pagerank coefficient between the user and other technical experts, user's activity index in the network security community, number of network security conferences or activities participated in by the user, badges obtained by the user, number of threat reports written by the user, and number of security incident responses participated by the user.

[0067] Among them, the user tag can be a tag of the user's own preference selected by the user. The user's security field level can be a coefficient calculated based on the articles browsed and commented on by the user. The more articles the user browses and the more profound the content of the browsed articles, the larger the coefficient, and the higher the security field level represented. The number of times the user attends network security courses can be determined based on the number of network security training courses the user has participated in. The pagerank coefficient between the user and other technical experts can be calculated based on the interactive relationship between the user's account and other technical experts (the specific calculation method of the pagerank coefficient is well known to those skilled in the art, and for the sake of brief description, it will not be repeated here). The number of network security meetings or activities participated by the user can be the number of online or offline network security related activities participated by the user, such as the Black Hat Conference, CIS (Comprehensive Intranet Security, Network Security Innovation Conference) Conference and other activities. The badge obtained by the user, that is, the honor obtained by the user in the network field, can be issued by a website, etc. The number of threat reports written by the user can be the number of threat intelligence reports contributed by the user. The number of security incident responses participated by the user can reflect the user's participation in actual security incidents.

[0068] In one implementation manner, the statistical features of an article may include at least one of the number of fans of the article author, the number of articles published by the author, the number of words in the article, the number and type of pictures included in the article, the multimedia content included in the article, the article tags, the article type, the average time the article is read, the number of days the article has been published, the number of likes on the article, the number of comments on the article, the number of shares on the article, the number of collections of the article, the click-through rate of the article, the bounce rate of the article, whether the user clicks on the article, and the number of interactions between the user and the article.

[0069] Among them, there are multiple tags and article types. Therefore, the tag type and article type can be onehot-encoded separately.

[0070] S200: Train the initial article recommendation model based on the training data set to obtain a trained article recommendation model.

[0071] After obtaining the training data set, the initial article recommendation model can be trained based on the training data set. The specific method and principle of the training model are well known to those skilled in the art and will not be described here for the sake of brief description.

[0072] In one implementation, the overall logic of the above article recommendation model training method can be as follows: Figure 2 shown.

[0073] First, data extraction and data processing can be performed, that is, a knowledge base can be obtained. At the same time, the environment is set up and the initial feature extraction model is prepared. After pre-training the initial feature extraction model using the knowledge base, the model can be evaluated and the feature extraction model with the best evaluation result can be saved. After that, user feature engineering (extracting user features) and article feature engineering (obtaining article word vectors and article statistical features) are performed to obtain a training data set. Then, the initial article recommendation model is trained using the training data set to obtain and save the trained article recommendation model.

[0074] Based on the same technical concept, this application also provides an article recommendation method, such as Figure 3 As shown, the following will be combined Figure 3 Describe the steps it involves.

[0075] S300: Obtain user features of a designated user, article statistical features and article word vectors corresponding to a number of articles to be recommended, and article statistical features and article word vectors corresponding to a target article.

[0076] The user characteristics of the user, the article statistical characteristics and article word vectors corresponding to the articles to be recommended, and the article statistical characteristics and article word vectors corresponding to the target article can be pre-acquired and stored in the database, and can be directly called when needed. Alternatively, they can be obtained in real time from a third-party device when needed.

[0077] Optionally, the article word vector corresponding to the article to be recommended and the article word vector corresponding to the target article may be extracted in real time based on the article to be recommended and the target article through a preset feature extraction model.

[0078] Optionally, a pre-trained feature extraction model may be used to obtain the article word vector corresponding to the target article and the article word vector corresponding to the articles to be recommended, and stored in the database. Then, before the article recommendation model is used to obtain the recommendation scores of the articles to be recommended, the article word vector corresponding to the target article and the article word vector corresponding to the articles to be recommended are obtained from the database.

[0079] Optionally, both the articles to be recommended and the target articles are articles in the field of network security.

[0080] Among them, the specific implementation method and principle of the feature extraction model have been clearly described in the previous article. For the sake of brief description, they will not be repeated here.

[0081] In one implementation, when recommending articles in the field of network security, user characteristics may include at least one of user behavior characteristics and user network security portrait characteristics.

[0082] Among them, user behavior characteristics represent the characteristics of users' operations on articles; while user network security portrait characteristics reflect the characteristics of users' knowledge structure in the field of network security.

[0083] The specific implementation methods and principles of user behavior characteristics, user network security profile characteristics, and article statistical characteristics have been clearly described in the previous article. For the sake of brief description, they will not be repeated here.

[0084] S400: Based on the article statistical features and article word vectors corresponding to the articles to be recommended, the article statistical features and article word vectors corresponding to the target article, and user characteristics, a pre-trained article recommendation model is used to obtain recommendation scores corresponding to the articles to be recommended.

[0085] For each article to be recommended, the article statistical features and article word vector corresponding to the article to be recommended, as well as the article statistical features and article word vector and user features corresponding to the target article are used as inputs to the pre-trained article recommendation model, and then the recommendation score output by the article recommendation model is obtained.

[0086] S500: Determine a recommended article based on the obtained recommendation scores corresponding to the plurality of articles to be recommended and recommend it to a designated user.

[0087] After obtaining the recommendation score corresponding to each article to be recommended, all articles to be recommended whose scores are greater than a preset threshold may be determined as recommended articles and recommended to the user. Alternatively, the N articles with the highest scores among all articles to be recommended may be determined as recommended articles and recommended to the user. Where N is a positive integer greater than or equal to 1. In this case, the higher the recommendation score, the more it indicates that the article should be recommended to the user.

[0088] If the lower the recommendation score, the more it should be recommended to the user, then after obtaining the recommendation score corresponding to each article to be recommended, all articles to be recommended whose scores are less than a preset threshold can be determined as recommended articles and recommended to the user. Alternatively, the N articles with the lowest scores among all articles to be recommended can be determined as recommended articles and recommended to the user. Where N is a positive integer greater than or equal to 1.

[0089] In order to facilitate understanding of the above article recommendation method, an example is given below to illustrate.

[0090] First, you can build a model running environment. In this case, you need to first establish a computing environment suitable for running the XLNet model. Taking Python as an example, the command to install the required dependent libraries can be: "pip install transformers".

[0091] Then you can load the pre-trained XLNet model (feature extraction model). You can use the transformers library to easily load the pre-trained XLNet model. You can import the XLNet tokenizer and model by: "from transformers import XLNetTokenizer, XLNetModel import torch

[0092] #Load the pre-trained XLNet tokenizer and model

[0093] tokenizer=XLNetTokenizer.from_pretrained('xlnet-base-cased')

[0094] model=XLNetModel.from_pretrained('xlnet-base-cased')".

[0095] After that, the document data can be preprocessed. Taking the cybersecurity articles on the Freebuf platform as an example dataset, each article can be converted into a word ID sequence through the XLNet tokenizer to prepare for the input of the feature extraction model (XLNet model). The sample code can be "#sample cybersecurity article

[0096] articles=[

[0097] "Article 1about network security...",

[0098] "Article 2on cybersecurity threats...",

[0099] "Article 3discussing firewall technologies...",

[0100] #Other articles ]

[0102] #Coding Articles

[0103] inputs=tokenizer(articles, padding=True, truncation=True, return_tensors='pt')".

[0104] After that, the article converted into a sequence of word ID (Identity Document) is converted into an article word vector. That is, the XLNet model is used to process the encoded article (the article converted into a sequence of word ID), and each article is represented by a feature vector, especially the last hidden state of the sequence is used as the overall article embedding of the article. The way to obtain the article embedding code can be "#Get model output

[0105] with torch.no_grad():

[0106] outputs = model(**inputs)

[0107] #Get the hidden state of the last layer

[0108] last_hidden_states=outputs.last_hidden_state

[0109] #Get the hidden state corresponding to the [CLS] tag as the article embedding

[0110] #Note: XLNet does not have an explicit [CLS] tag, here we use the vector at the last position to represent the entire sequence

[0111] article_embeddings=last_hidden_states[:,-1,:]

[0112] print(article_embeddings.shape)#The output should be (num_articles, hidden_size)".

[0113] Since user behavior characteristics and user network security profile characteristics will not change dramatically in a short period of time, a preset time (such as night, etc.) can be set every day to calculate the user behavior characteristics and user network security profile characteristics of the user at the preset time and store them in the database. When in use, the user behavior characteristics and user network security profile characteristics of the user can be directly queried from the database.

[0114] Since the content of each article will not change, the word vector of the article can be generated in advance and then stored in the database. When an article recommendation is needed, the word vector corresponding to the article (which can be the article to be recommended or the target article) can be directly searched from the database.

[0115] However, since the article statistical features of each article may change in real time, the article statistical features may be generated in real time.

[0116] Then, the trained transformer model (i.e., article recommendation model) can be used to recommend articles. The aforementioned user behavior features, user network security profile features, article statistical features and article word vectors corresponding to the articles to be recommended, and article statistical features and article word vectors corresponding to the target articles are combined to obtain the recommendation scores corresponding to the articles to be recommended. Finally, based on the obtained recommendation scores corresponding to the articles to be recommended, the recommended articles are determined and recommended to the specified users.

[0117] For example, the recommendation scores corresponding to a number of articles to be recommended may be obtained, and then all the recommendation scores are sorted in reverse order, and the K articles to be recommended with the highest recommendation scores are selected for recommendation, where K is a positive integer.

[0118] One implementation of the recommended function could be "import numpy as np

[0119] def recommend_articles(article_index,similarity_matrix,top_k=5):

[0120] #Get the recommendation score of the specified article

[0121] similarity_scores=similarity_matrix[article_index]

[0122] #Get the index of the article with the highest recommendation score (excluding itself)

[0123] similar_indices=np.argsort(similarity_scores)[::-1]

[0124] similar_indices=similar_indices[similar_indices! =article_index]

[0125] #Return the top K articles with the highest recommendation scores".

[0126] Based on the same technical concept, the present application also provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the above-mentioned article recommendation method and / or article recommendation model training method are implemented.

[0127] The computer program product may be, for example, a program package, an APP (mobile phone application software), etc. The computer program product includes but is not limited to the methods exemplified here.

[0128] See also Figure 4 , which is an electronic device 100 provided in an embodiment of the present application. The electronic device 100 includes: a processor 110 and a memory 120.

[0129] The memory 120 and the processor 110 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these elements can be electrically connected to each other through one or more communication buses or signal lines. Among them, the memory 120 is used to store computer programs, such as the above-mentioned computer program product. Among them, the computer program product includes at least one software function module that can be stored in the memory 120 in the form of software or firmware or solidified in the operating system (OS) of the electronic device 100. The processor 110 is used to execute the executable module stored in the memory 120. At this time, the processor 110 is used to obtain a training data set, and the training data set includes multiple training data, each training data includes user features, article statistical features and article word vectors corresponding to the specified article, and article statistical features and article word vectors corresponding to the article to be recommended, and each training data is marked with a label representing whether it is recommended; the initial article recommendation model is trained based on the training data set to obtain a trained article recommendation model.

[0130] Among them, the memory 120 can be, but is not limited to, RAM (Random Access Memory), ROM (Read Only Memory), PROM (Programmable Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electric Erasable Programmable Read-Only Memory), etc.

[0131] The processor 110 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a CPU (Central Processing Unit), an NP (Network Processor), etc.; it may also be a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. A general-purpose processor may be a microprocessor or the processor 110 may also be any conventional processor, etc.

[0132] The electronic device 100 mentioned above includes but is not limited to a personal computer, a server, etc.

[0133] The embodiment of the present application also provides a computer-readable storage medium (hereinafter referred to as storage medium), on which a computer program is stored. When the computer program is run by a computer such as the above-mentioned electronic device 100, the article recommendation model training method or article recommendation method shown above is executed. The computer-readable storage medium includes: a U disk, a mobile hard disk, a read-only memory, a random access memory, a magnetic disk or an optical disk, and other media that can store program codes.

[0134] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A training method for an article recommendation model, characterized in that: include: Obtain a training data set, wherein the training data set includes multiple training data, each training data includes user features, article statistical features and article word vectors corresponding to a specified article, and article statistical features and article word vectors corresponding to the article to be recommended, and each training data is annotated with a label indicating whether it is recommended; The initial article recommendation model is trained based on the training data set to obtain a trained article recommendation model.

2. The method according to claim 1, characterized in that The designated article is an article that the user clicks to read on a designated website, and the articles to be recommended are several articles that the designated website recommends to the user when the user clicks to read the designated article.

3. The method according to claim 2, characterized in that Get the training dataset, including: Get the user's browsing history on the specified website; According to the browsing history, the articles to be recommended clicked by the user in the process of reading the designated article are marked with a label indicating recommendation, and the articles to be recommended not clicked by the user are marked with a label indicating non-recommendation.

4. The method according to claim 1, characterized in that Also includes: Acquire knowledge information in the professional field of the designated article, and preprocess the knowledge information to form a knowledge base; Pre-training an initial feature extraction model using the knowledge base to obtain a feature extraction model; The article word vector corresponding to the designated article and the article word vector corresponding to the article to be recommended are extracted through the feature extraction model.

5. The method according to any one of claims 1 to 4, characterized in that: The designated article and the article to be recommended are both articles in the field of network security; accordingly, the user characteristics include user behavior characteristics and user network security portrait characteristics; wherein the user behavior characteristics represent the characteristics of the user's operation on the article; the user network security portrait characteristics reflect the user's knowledge structure characteristics in the field of network security.

6. A method for recommending articles, characterized in that: include: Obtain user features of the specified user, article statistical features and article word vectors corresponding to several articles to be recommended, and article statistical features and article word vectors corresponding to the target article; Based on the article statistical features and article word vectors corresponding to the articles to be recommended, the article statistical features and article word vectors corresponding to the target article, and the user characteristics, using a pre-trained article recommendation model, obtaining recommendation scores corresponding to the articles to be recommended; Based on the obtained recommendation scores corresponding to the plurality of articles to be recommended, a recommended article is determined and recommended to the designated user.

7. The method according to claim 6, characterized in that Also includes: Using a pre-trained feature extraction model, obtain the article word vector corresponding to the target article and the article word vectors corresponding to the articles to be recommended, and store them in a database; Before obtaining the recommendation scores of the articles to be recommended by using the article recommendation model, the article word vector corresponding to the target article and the article word vectors corresponding to the articles to be recommended are obtained from the database.

8. The method according to claim 6, characterized in that The articles to be recommended and the target articles are both articles in the field of network security.

9. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are connected; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 1 to 8.

10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.