Knowledge recommendation method and device, electronic equipment and storage medium
By obtaining and processing user log information, and using one-hot encoding and knowledge recommendation models to generate personalized recommendations, it solves the problem of lack of personalization in information overload in traditional recommendation systems, and improves recommendation accuracy and user experience.
Patent Information
- Application Number
- CN202411464831.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-18
- Publication Date
- 2025-01-24
AI Technical Summary
When traditional recommendation systems face massive information, it is difficult to achieve personalized recommendations, resulting in users being unable to effectively obtain knowledge of interest.
By obtaining log information, use the monopoly coding to convert it into an information matrix, and input the knowledge recommendation model, output predictive requirements probability sequence, and generate personalized recommendation knowledge.
Recommended personalized knowledge recommendations, improved the efficiency and accuracy of recommendation, improved the user experience, and reduced the time for users to find useful information in the ocean of information.
Smart Images

Figure CN119358704A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine learning technology, and in particular to a knowledge recommendation method and device, an electronic device, and a storage medium. Background Art
[0002] With the rapid development of the times, while massive amounts of information allow people to enjoy the pleasure of the information age, it also brings another problem, that is, users are faced with a large amount of useless information. At the same time, traditional recommendation systems usually face problems of information overload and lack of personalization. Users need to filter out the parts that are useful to them from a large amount of knowledge or content, which makes it impossible for users to effectively obtain the knowledge that they are interested in and that is valuable to them.
[0003] In summary, the technical problems existing in the relevant technologies need to be improved. Summary of the invention
[0004] The main purpose of the embodiments of the present application is to propose a knowledge recommendation method and device, an electronic device and a storage medium, aiming to achieve personalized knowledge recommendation and improve the efficiency and accuracy of knowledge recommendation.
[0005] To achieve the above objective, an embodiment of the present application provides a knowledge recommendation method, which includes the following steps:
[0006] Get log information;
[0007] Convert the log information into an information matrix by one-hot encoding, and input the information matrix into a knowledge recommendation model;
[0008] Outputting a predicted demand probability sequence through the knowledge recommendation model;
[0009] Generate recommended knowledge according to the predicted demand probability sequence.
[0010] In some embodiments, obtaining log information includes:
[0011] In response to the first instruction, obtaining log authorization information;
[0012] If the log authorization information includes that the user has authorized the log information, the log information is obtained and entered.
[0013] In some embodiments, outputting a predicted demand probability sequence through the knowledge recommendation model includes:
[0014] Obtaining a number of predicted demand probabilities through the knowledge recommendation model, wherein the predicted demand probabilities include knowledge module identifiers and predicted probabilities;
[0015] The predicted demand probabilities are arranged in descending order according to the predicted probabilities to obtain a predicted demand probability sequence.
[0016] In some embodiments, converting the log information into an information matrix by one-hot encoding includes:
[0017] Obtain the module encoding of the knowledge module through one-hot encoding;
[0018] Constructing a two-dimensional matrix according to the module code and the log information;
[0019] The two-dimensional matrix is converted into a three-dimensional matrix to obtain an information matrix.
[0020] In some embodiments, the log information includes multiple click logs, the click log includes a knowledge module identifier, a total number of clicks corresponding to the knowledge module, and a visit duration corresponding to the knowledge module, the knowledge module identifier corresponds to the module code, and constructing a two-dimensional matrix according to the log information includes:
[0021] Generate a one-dimensional matrix corresponding to each click log according to the module code corresponding to the knowledge module identifier, the access duration corresponding to the knowledge module, and the total number of clicks corresponding to the knowledge module;
[0022] The one-dimensional matrices are combined to obtain a two-dimensional matrix.
[0023] In some embodiments, the method further comprises the step of training a knowledge recommendation model;
[0024] The training knowledge recommendation model includes:
[0025] Receive a log information sample of a sample user, wherein the log information sample includes at least the number of clicks of the sample user to access each knowledge module and the access duration of each click;
[0026] Generate a predicted demand probability sequence of sample users for each knowledge module based on the log information sample through the knowledge recommendation model to be trained;
[0027] The knowledge recommendation model is trained according to the predicted demand probability sequence and the real demand probability sequence of the log information sample. When the error between the predicted demand probability sequence and the real demand probability sequence is within a preset range, the trained knowledge recommendation model is obtained.
[0028] In some embodiments, the knowledge recommendation model includes a serially connected input embedding layer, a discrete cosine perception layer, and a first fully connected layer, and outputting a predicted demand probability sequence through the knowledge recommendation model includes:
[0029] Receiving the information matrix through the input embedding layer, generating a first feature map, and inputting the first feature map into the discrete cosine perception layer;
[0030] Convert the first feature map to the frequency domain through the discrete cosine perception layer to obtain a second feature map, and input the second feature map into the first fully connected layer;
[0031] The second feature map is received through the first fully connected layer, and a predicted demand probability sequence is output.
[0032] In some embodiments, the discrete cosine perception layer includes eight discrete cosine perception structures; the discrete cosine perception structure includes a first normalization layer, a discrete cosine transform structure, a second normalization layer and a perceptual attention feature extractor connected in series, and the first feature map is converted into a frequency domain through the discrete cosine perception layer to obtain a second feature map, including:
[0033] receiving the first feature map through the first normalization layer, generating a normalized third feature map, and inputting the second feature map into the discrete cosine transform structure;
[0034] Receiving the third feature map through the discrete cosine transform structure to obtain a fourth feature map for extracting frequency domain features, superimposing the third feature map with the fourth feature map to generate a fifth feature map, and inputting the fifth feature map into the second normalization layer;
[0035] receiving the fifth feature map through the second normalization layer, generating a normalized sixth feature map, and inputting the sixth feature map into the perceptual attention feature extractor;
[0036] The sixth feature map is received by the perceptual attention feature extractor, a seventh feature map is further extracted and superimposed with the fifth feature map to generate an eighth feature map, and the eighth feature map is output.
[0037] To achieve the above-mentioned purpose, another aspect of the embodiment of the present application provides a knowledge recommendation device, the device comprising:
[0038] Log acquisition module, used to obtain log information;
[0039] A matrix conversion module, used for converting the log information into an information matrix through one-hot encoding, and inputting the information matrix into a knowledge recommendation model;
[0040] A sequence output module, used to output a predicted demand probability sequence through the knowledge recommendation model;
[0041] The knowledge generation module is used to generate recommended knowledge according to the predicted demand probability sequence.
[0042] To achieve the above-mentioned purpose, another aspect of an embodiment of the present application provides an electronic device, the electronic device comprising a memory and a processor, the memory storing a computer program, and the processor implementing the above-mentioned method when executing the computer program.
[0043] To achieve the above objective, another aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described above is implemented.
[0044] The embodiments of the present application include at least the following beneficial effects: the present application provides a knowledge recommendation method and device, an electronic device and a storage medium, which helps to understand user needs and preferences by obtaining log information; converts log information into an information matrix through one-hot encoding, and inputs the information matrix into a knowledge recommendation model, which helps the model understand the diversity of user behavior and thus generate more accurate recommendations; outputs a predicted demand probability sequence through the knowledge recommendation model; generates recommended knowledge based on the predicted demand probability sequence to achieve personalized knowledge recommendation, thereby improving the efficiency and accuracy of knowledge recommendation and enhancing user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 is a flow chart of the knowledge recommendation method provided in an embodiment of the present application;
[0046] Figure 2 yes Figure 1 Flow chart of step S102 in FIG.
[0047] Figure 3 yes Figure 2 Flow chart of step S202 in FIG.
[0048] Figure 4 It is a flowchart of the steps of training a knowledge recommendation model of the knowledge recommendation method provided in an embodiment of the present application;
[0049] Figure 5 yes Figure 1 Flow chart of step S103 in FIG.
[0050] Figure 6 is another flow chart of the knowledge recommendation method provided in the embodiment of the present application;
[0051] Figure 7 It is a schematic diagram of an information matrix provided in an embodiment of the present application;
[0052] Figure 8 This is a flow chart of the knowledge recommendation model outputting a predicted demand probability sequence provided by an embodiment of the present application;
[0053] Fig. 9It is a schematic diagram of a discrete cosine perception structure and a perception attention feature extractor provided in an embodiment of the present application;
[0054] Fig.10 is a schematic diagram of the structure of a knowledge recommendation device provided in an embodiment of the present application;
[0055] Fig.11 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0056] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the embodiments of the present application. They are only examples of devices and methods consistent with some aspects of the embodiments of the present application as detailed in the attached claims.
[0057] It is understood that the terms "first", "second", etc. used in this application can be used to describe various concepts in this article, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. For example, without departing from the scope of the embodiment of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" and "if" as used herein can be interpreted as "at the time of" or "when" or "in response to determination".
[0058] The terms "at least one", "multiple", "each", "any", etc. used in this application, at least one includes one, two or more, multiple includes two or more, each refers to each of the corresponding multiple, and any refers to any one of the multiple.
[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.
[0060] Before describing the embodiments of the present application in detail, some nouns and terms involved in the embodiments of the present application are first described. The nouns and terms involved in the embodiments of the present application are subject to the following explanations.
[0061] 1) Softmax (normalized exponential function) is the logarithmic normalization of the gradient of a finite discrete probability distribution. Therefore, the Softmax function is widely used in a variety of probability-based multi-classification problem methods including multinomial logistic regression, multinomial linear discriminant analysis, naive Bayes classifier and artificial neural network.
[0062] 2) One-hot encoding, also known as one-bit effective encoding, uses an N-bit state register to encode N states. Each state has its own independent register bit, and at any time, only one of them is valid.
[0063] 3) Transformer, a deep learning model, was originally designed to improve machine translation tasks, but has since been widely used in various natural language processing (NLP) tasks, including text classification, question answering systems, text summarization, etc.
[0064] With the rapid development of the times, while massive amounts of information allow people to enjoy the pleasure of the information age, it also brings another problem, that is, users are faced with a large amount of useless information. At the same time, traditional recommendation systems usually face problems of information overload and lack of personalization. Users need to filter out the parts that are useful to them from a large amount of knowledge or content, which makes it impossible for users to effectively obtain the knowledge that they are interested in and that is valuable to them.
[0065] For example, with the vigorous development of the sports industry and the improvement of national fitness awareness, it is crucial for various systems in the sports industry to scientifically meet the needs of different users. In a complex network environment, users are faced with a large amount of useless sports information, and traditional sports information recommendation systems are mostly based on static rules or keyword matching, often ignoring the personalized needs of users, and unable to dynamically recommend based on user behavior and interests. The sports knowledge recommended by the system may not match the current needs of users, resulting in poor relevance of the recommendation results.
[0066] In summary, the technical problems existing in the relevant technologies need to be improved.
[0067] In view of this, a knowledge recommendation method, apparatus, device and medium are provided in the embodiments of the present application. The scheme helps to understand user needs and preferences by obtaining log information; converts log information into an information matrix through one-hot encoding, and inputs the information matrix into a knowledge recommendation model, which helps the model understand the diversity of user behavior and thus generate more accurate recommendations; outputs a predicted demand probability sequence through the knowledge recommendation model; generates recommended knowledge based on the predicted demand probability sequence to achieve personalized knowledge recommendation, thereby improving the efficiency and accuracy of knowledge recommendation and enhancing user experience.
[0068] The knowledge recommendation method provided in the embodiment of the present application relates to the field of machine learning technology. The knowledge recommendation method provided in the embodiment of the present application can be applied to a terminal, can also be applied to a server, and can also be software running in a terminal or a server. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart watch, and a car terminal, etc., but is not limited to this; the server side can be configured as an independent physical server, or it can be configured as a server cluster or distributed system composed of multiple physical servers, and can also be configured to provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms and other basic cloud computing services. The server can also be a node server in the blockchain network; the software can be an application that implements the knowledge recommendation method, etc., but is not limited to the above forms.
[0069] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.
[0070] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.
[0071] Figure 1 is an optional flow chart of the knowledge recommendation method provided in the embodiment of the present application. Figure 1The method may include but is not limited to steps S101 to S104.
[0072] Step S101, obtaining log information.
[0073] Specifically, the log information includes a plurality of click logs, and the click logs at least include the identifier of the knowledge module clicked and accessed by the user and the access duration.
[0074] In some embodiments, in response to the first instruction, log authorization information is obtained; if the log authorization information includes that the user has authorized the log information, the log information is obtained and entered. The first instruction is to receive knowledge acquisition request information from the user.
[0075] It is understandable that the log information can be obtained from the system or database.
[0076] Furthermore, the obtained log information is preprocessed, including removing invalid data, filling missing values and standardizing the format.
[0077] In this embodiment, obtaining log information is helpful for understanding user needs and preferences.
[0078] Step S102: convert the log information into an information matrix through one-hot encoding, and input the information matrix into the knowledge recommendation model.
[0079] Specifically, the knowledge recommendation model is a pre-trained model, and the log information includes the number of clicks corresponding to the knowledge module and the number of knowledge modules. The number of log information types is determined according to the type of log information (such as the number of clicks and the number of knowledge modules).
[0080] Optionally, the knowledge recommendation model can adopt a deep learning model.
[0081] In some embodiments, the module code of each knowledge module is obtained by one-hot encoding; a two-dimensional matrix is constructed according to the module code and the log information; and the two-dimensional matrix is converted into an information matrix. The size of the rows and columns of the two-dimensional matrix is determined by the number of clicks, the number of knowledge modules, and the number of types of log information. The number of rows of the two-dimensional matrix is the number of clicks, and the number of columns is the sum of the number of knowledge modules and the number of types of log information. The log information (such as user behavior, timestamp, event type, etc.) is converted into a sparse matrix form. Each category (for example, different user behaviors) is represented as a binary vector.
[0082] Optionally, a one-dimensional matrix is generated for each click log, all the one-dimensional matrices are merged into a two-dimensional matrix, and the two-dimensional matrix is converted into an information matrix, and the information matrix adopts an N-dimensional matrix corresponding to the knowledge recommendation model. Among them, the number of columns of the one-dimensional matrix is determined by the module code and the number of log information types. Exemplarily, if the module code is 3 bits and the number of log information types is 2 (i.e., the access duration and the total number of clicks), the number of columns of the one-dimensional matrix is 5.
[0083] It is understandable that the dimension of the information matrix is determined by the knowledge recommendation model. Exemplarily, if a three-dimensional matrix is used when training the knowledge recommendation model, a three-dimensional matrix also needs to be constructed when constructing the information matrix.
[0084] Among them, in the system database, the identifier of each knowledge module recorded in the access log (that is, the module code of each knowledge module), the number of clicks corresponding to each knowledge module and other log information are obtained, and the user's information matrix is constructed, and the user's log information is converted into a structured form to help preprocess and clean the original data, eliminate noise and redundant information in the data, thereby improving the efficiency and accuracy of subsequent data processing and analysis, and facilitating subsequent data processing and analysis.
[0085] In this embodiment, the log information is converted into an information matrix through one-hot encoding, and the information matrix is input into the knowledge recommendation model, which helps the model understand the diversity of user behaviors and thus generate more accurate recommendations.
[0086] Step S103: output the predicted demand probability sequence through the knowledge recommendation model.
[0087] Specifically, the predicted demand probability sequence includes multiple predicted demand probabilities, and the predicted demand probability includes a knowledge module identifier and a predicted probability.
[0088] In some embodiments, a number of predicted demand probabilities are obtained through the knowledge recommendation model, and the predicted demand probabilities include knowledge module identifiers and predicted probabilities; the predicted demand probabilities are arranged in descending order according to the predicted probabilities to obtain a predicted demand probability sequence, wherein the knowledge module identifiers correspond to the predicted probabilities one by one.
[0089] It can be understood that the demand probability sequence represents the degree of interest of the user in each knowledge module, and the sports knowledge modules are pushed to the user in this order in the system. For example, the knowledge modules are identified as badminton, running, and weight loss, and the predicted demand probabilities are weight loss-46%, badminton-70%, and running-50%. The demand probability sequence represents the ranking of the probability of the user's interest in badminton, running, and weight loss. Among them, the demand probability sequence is arranged in descending order according to the predicted probability. Exemplarily, the demand probability sequence includes badminton-70%, running-50%, and weight loss-46%.
[0090] In this embodiment, outputting a predicted demand probability sequence through a knowledge recommendation model is conducive to improving the accuracy of recommendations and can provide personalized knowledge recommendations based on the actual needs of users.
[0091] Step S104: Generate recommended knowledge based on the predicted demand probability sequence.
[0092] In some embodiments, the knowledge is sorted according to the predicted demand probability sequence, and several pieces of knowledge with the highest probability are selected as recommended knowledge.
[0093] Furthermore, the recommended knowledge can be adjusted according to the user's current context (such as time and location) so that the recommended knowledge is more in line with the user's immediate needs.
[0094] In this embodiment, recommended knowledge is generated according to the predicted demand probability sequence to achieve personalized knowledge recommendation, thereby improving the efficiency and accuracy of knowledge recommendation, enhancing user experience, avoiding users from blindly searching in a large amount of information, and saving users time in acquiring knowledge.
[0095] Steps S101 to S104 shown in the embodiment of the present application help understand user needs and preferences by obtaining log information; converting log information into an information matrix through one-hot encoding, and inputting the information matrix into a knowledge recommendation model, which helps the model understand the diversity of user behaviors and thus generate more accurate recommendations; outputting a predicted demand probability sequence through the knowledge recommendation model; generating recommended knowledge based on the predicted demand probability sequence to achieve personalized knowledge recommendation, thereby improving the efficiency and accuracy of knowledge recommendation, enhancing user experience, avoiding users from blindly searching in a large amount of information, and saving users time in acquiring knowledge.
[0096] See also Figure 2 In some embodiments, step S102 may include but is not limited to steps S201 to S203:
[0097] Step S201, obtaining the module code of the knowledge module through one-hot encoding.
[0098] In step S201 of some embodiments, the module code of the knowledge module is obtained by one-hot encoding. For example, if three modules of "diet", "weight loss" and "fitness action guidance" are used, the module code length of the knowledge module is 3, the code of diet is 100, the code of weight loss is 010, and the code of fitness action guidance is 001.
[0099] Step S202: construct a two-dimensional matrix according to the module code and log information.
[0100] Specifically, the log information includes a plurality of click logs, and the click log includes a knowledge module identifier, a total number of clicks corresponding to the knowledge module, and a visit duration corresponding to the knowledge module, and the knowledge module identifier corresponds to the module code.
[0101] In step S202 of some embodiments, a one-dimensional matrix corresponding to each click log is generated according to the module code corresponding to the knowledge module identifier, the access duration corresponding to the knowledge module, and the total number of clicks corresponding to the knowledge module; the one-dimensional matrices are combined to obtain a two-dimensional matrix.
[0102] Optionally, since the one-hot encoded matrix is usually sparse, a sparse matrix can be used to store it to save memory.
[0103] Step S203, converting the two-dimensional matrix into a three-dimensional matrix to obtain an information matrix.
[0104] The present application does not specifically limit the dimension of the information matrix, and it can be flexibly selected in combination with actual detection needs. For example, the information matrix can be a three-dimensional matrix or a two-dimensional matrix.
[0105] See also Figure 3 In some embodiments, step S202 may include but is not limited to steps S301 to S302:
[0106] Step S301, generating a one-dimensional matrix corresponding to each click log according to the module code corresponding to the knowledge module identifier, the access duration corresponding to the knowledge module, and the total number of clicks corresponding to the knowledge module.
[0107] It is understandable that the total number of clicks reflects the user's click frequency, and the access duration of the current click reflects the user's stickiness preference, so that the model's prediction can fully consider the frequency and duration information, thereby improving the prediction accuracy.
[0108] In step S301 of some embodiments, the corresponding module code is determined according to the knowledge module identifier of the log information, and then a one-dimensional matrix corresponding to each click log is generated through the module code corresponding to the knowledge module identifier, the access time corresponding to the knowledge module, and the total number of clicks corresponding to the knowledge module.
[0109] For example, the module code for diet is 100, the module code for weight loss is 010, and the module code for fitness action guidance is 001. Assuming that the "diet" label is clicked twice, each visit lasts for 5 minutes and 10 minutes respectively, and the "weight loss" label is clicked once, the visit lasts for 8 minutes, then the one-dimensional matrix representing the first click on diet is [1,0,0,5,2], the one-dimensional matrix representing the second click on diet is [1,0,0,10,2], and the one-dimensional matrix representing the first click on weight loss is [0,1,0,8,1].
[0110] Among them, the column 5 of the one-dimensional matrix represents the sum of the number of knowledge modules and the number of log information types (i.e., access time and total number of clicks). The first to third numbers in the one-dimensional matrix are module codes, the fourth number represents the access time of this click; the fifth number represents the total number of clicks on this knowledge module.
[0111] Step S302: combine the one-dimensional matrices to obtain a two-dimensional matrix.
[0112] In step S302 of some embodiments, the one-dimensional matrices corresponding to all click logs are combined to obtain a two-dimensional matrix.
[0113] Further, the two-dimensional matrix is converted into an information matrix required by the knowledge recommendation model. Exemplarily, the two-dimensional matrix is converted into a three-dimensional matrix required by the knowledge recommendation model.
[0114] See also Figure 4 In some embodiments, the knowledge recommendation method provided in the embodiment of the present application further includes a step of training a knowledge recommendation model. The step of training a knowledge recommendation model may include but is not limited to steps S401 to S403:
[0115] Step S401: receiving a sample of log information of a sample user.
[0116] Specifically, the log information sample includes at least the number of clicks by the sample user to access each knowledge module and the access duration of each click.
[0117] Receive log information samples of sample users; obtain the predicted demand probability ranking of sample users for each knowledge module based on the log information samples of sample users; train the knowledge recommendation model to be trained based on the predicted demand probability ranking of the samples and the actual demand probability ranking of the samples until the error between the predicted demand probability ranking and the actual demand probability ranking is within an allowable range; wherein the log information at least includes the number of clicks of users to visit each knowledge module and the access duration of each click.
[0118] Step S402 : generating a predicted demand probability sequence of sample users for each knowledge module according to log information samples through the knowledge recommendation model to be trained.
[0119] Specifically, the knowledge recommendation model includes a serially connected input embedding layer, a discrete cosine perception layer and a first fully connected layer; the discrete cosine perception layer includes at least one discrete cosine perception structure.
[0120] In step S402 of some embodiments, the knowledge recommendation model to be trained periodically generates a predicted demand probability sequence of sample users for each knowledge module based on the log information sample, and the knowledge recommendation model is trained based on the predicted demand probability sequence and the actual demand probability sequence of the log information sample until the error between the predicted demand probability sequence and the actual demand probability sequence is within a preset range.
[0121] Step S403, training the knowledge recommendation model according to the predicted demand probability sequence and the actual demand probability sequence of the log information sample, and obtaining the trained knowledge recommendation model when the error between the predicted demand probability sequence and the actual demand probability sequence is within a preset range.
[0122] Specifically, the log information samples have corresponding real demand probability sequences.
[0123] In step S403 of some embodiments, when the error between the predicted demand probability sequence and the actual demand probability sequence is within a preset range, the error of the knowledge recommendation model is considered to be reasonable, and a trained knowledge recommendation model is obtained.
[0124] See also Figure 5 In some embodiments, the knowledge recommendation model includes a serially connected input embedding layer, a discrete cosine perception layer, and a first fully connected layer. Step S103 may also include, but is not limited to, steps S501 to S503:
[0125] Step S501, receiving the information matrix through the input embedding layer, generating a first feature map, and inputting the first feature map into the discrete cosine perception layer.
[0126] In step S501 of some embodiments, the input embedding layer is configured to receive the information matrix, generate an extracted first feature map, and input the first feature map into the discrete cosine perception layer.
[0127] Step S502: convert the first feature map into the frequency domain through the discrete cosine perception layer to obtain a second feature map, and input the second feature map into the first fully connected layer.
[0128] Specifically, the discrete cosine perception layer includes at least one discrete cosine perception structure; the discrete cosine perception structure includes a first normalization layer, a discrete cosine transform structure, a second normalization layer and a perceptual attention feature extractor connected in series. The perceptual attention feature extractor includes a first part, a second part and a third part; the first part includes a second fully connected layer, an activation function layer and a random dropout layer connected in series; the second part includes a third fully connected layer, a Softmax layer and a fourth fully connected layer connected in series; the third part includes a fourth fully connected layer and a random dropout layer connected in series.
[0129] In step S502 of some embodiments, DCT is applied to the first feature map to extract its frequency features to obtain a second feature map, and the second feature map is input into the first fully connected layer.
[0130] Optionally, the first normalization layer is configured to receive the first feature map, generate a normalized third feature map, and input the third feature map into a discrete cosine transform structure; the discrete cosine transform structure is configured to receive the third feature map, obtain a fourth feature map for extracting frequency domain features, superimpose the third feature map with the fourth feature map, generate a fifth feature map, and input the fifth feature map into the second normalization layer; the second normalization layer is configured to receive the fifth feature map, generate a normalized sixth feature map, and input the sixth feature map into a perceptual attention feature extractor; the perceptual attention feature extractor is configured to receive the sixth feature map, further extract the seventh feature map and superimpose it with the fifth feature map to generate an eighth feature map, and output the eighth feature map.
[0131] It can be understood that the input of the discrete cosine perception structure (i.e., the first feature map) first undergoes a layer normalization operation (i.e., receiving the first feature map and generating a normalized third feature map), and then passes through a discrete cosine transform structure; the input of the discrete cosine transform structure (i.e., the third feature map) first passes through a discrete cosine transform, and the result obtained (i.e., the fourth feature map) is added to the input of the discrete cosine transform structure (i.e., the third feature map) to obtain the final output result of the discrete cosine transform structure (i.e., the fifth feature map); the output of the discrete cosine transform structure (i.e., the fifth feature map) and the input of the current discrete cosine perception structure (i.e., the first feature map) are first added, and then undergo a layer normalization; the output (i.e., the sixth feature map) is then passed through a perceptual attention feature extractor, and the output of the perceptual attention feature extractor (i.e., the seventh feature map) and the output obtained by the previous addition operation (i.e., the fifth feature map) are added to obtain the final output result of this discrete cosine perception structure (i.e., the eighth feature map).
[0132] Among them, the eighth feature map output by the last discrete cosine perception structure of the discrete cosine perception layer is the second feature map. The eighth feature map is input into the first fully connected layer to output the predicted demand probability sequence.
[0133] In other embodiments, the first part of the perceptual attention feature extractor is configured to receive the sixth feature map, generate a ninth feature map, and input the ninth feature map into the second part; the second part of the perceptual attention feature extractor is configured to receive the ninth feature map, generate a weight value, weight the ninth feature map according to the weight value, generate a tenth feature map, and input the tenth feature map into the fully connected layer; the third part of the perceptual attention feature extractor is configured to receive the tenth feature map and output the seventh feature map.
[0134] The second feature map may include the tenth feature map, the tenth feature map is input into the first fully connected layer, and the predicted demand probability sequence is output.
[0135] It can be understood that the third part of the perceptual attention feature extractor and the first fully connected layer can both output predicted demand probability rankings.
[0136] Step S503, receiving the second feature map through the first fully connected layer, and outputting a predicted demand probability sequence.
[0137] In step S503 of some embodiments, the output of the discrete cosine perception layer is flattened by the first fully connected layer and then passed through a fully connected layer to obtain the probability that the user is interested in each knowledge module, thereby obtaining a predicted demand probability sequence.
[0138] Figure 6 is another optional flow chart of the knowledge recommendation method provided in the embodiment of the present application. Figure 6 The method may include but is not limited to steps S601 to S606.
[0139] Step S601, in response to receiving the knowledge acquisition request information of the user, obtaining the user's authorization for the log information, and entering the log information after obtaining the user's authorization for the log information.
[0140] The log information includes multiple click logs, and the click logs at least include the identifier of the knowledge module clicked by the user and the access duration.
[0141] Step S602: convert the log information into an information matrix through one-hot encoding, and input the information matrix into a pre-trained knowledge recommendation model.
[0142] In this embodiment, the information matrix diagram is as follows: Figure 7As shown, first one-hot encode the knowledge module. Assume that there are three labels: "diet", "weight loss", and "fitness action guidance", and the log information is the access time and the total number of clicks. Then the one-hot vector length is 3, the encoding of diet is 100, the encoding of weight loss is 010, and the encoding of fitness action guidance is 001. Assume that the "diet" label is clicked twice, with each access time of 5 minutes and 10 minutes respectively, and the "weight loss" label is clicked once, with a access time of 8 minutes. Then the one-dimensional matrix representing the first click on diet is [1,0,0,5,2], the one-dimensional matrix representing the second click on diet is [1,0,0,10,2], and the one-dimensional matrix representing the first click on weight loss is [0,1,0,8,1]. By combining three one-dimensional matrices from top to bottom, a matrix with a shape of (1,3,5) is constructed. Among them, 3 represents a total of three clicks; 5 represents the sum of the number of knowledge modules and the number of log information types. The first to third numbers in the one-dimensional matrix are one-hot codes, the fourth number represents the access duration of this click; the fifth number represents the total number of clicks on this knowledge module.
[0143] Step S603, converting the information matrix into a feature map suitable for the Transformer architecture through an input embedding layer.
[0144] Specifically, the knowledge recommendation model includes a serially connected input embedding layer, a discrete cosine perception layer, and a first fully connected layer.
[0145] In some embodiments, the information matrix is converted into a first feature map suitable for a Transformer architecture through an input embedding layer.
[0146] For example, the flow chart of the knowledge recommendation model outputting the predicted demand probability sequence is as follows: Figure 8 As shown in the figure, the input is passed through an input embedding layer to convert the data into a feature map suitable for the Transformer architecture; the output of the input embedding layer is connected in series through a discrete cosine perception layer; the output of the discrete cosine perception layer is flattened and passed through a fully connected layer to obtain the probability that the user is interested in each knowledge module.
[0147] Step S604, the output of the input embedding layer is connected in series through the discrete cosine perception layer.
[0148] Specifically, the discrete cosine perception layer includes eight discrete cosine perception structures.
[0149] It is understandable that if Figure 8 As shown, the eighth feature map output by the last discrete cosine perception structure of the discrete cosine perception layer is the second feature map. The eighth feature map is input into the first fully connected layer to output the predicted demand probability sequence.
[0150] In some embodiments, a first normalization layer receives a first feature map, generates a normalized third feature map, and inputs the second feature map into a discrete cosine transform structure; the discrete cosine transform structure receives the third feature map, obtains a fourth feature map for extracting frequency domain features, superimposes the third feature map with the fourth feature map to generate a fifth feature map, and inputs the fifth feature map into a second normalization layer; the second normalization layer receives the fifth feature map, generates a normalized sixth feature map, and inputs the sixth feature map into a perceptual attention feature extractor; the perceptual attention feature extractor receives the sixth feature map, further extracts a seventh feature map and superimposes it with the fifth feature map to generate an eighth feature map, and outputs the eighth feature map.
[0151] Furthermore, the first part of the perceptual attention feature extractor receives the sixth feature map, generates a ninth feature map, and inputs the ninth feature map into the second part; the second part receives the ninth feature map, generates a weight value, weights the ninth feature map according to the weight value, generates a tenth feature map, and inputs the tenth feature map into the fully connected layer; the third part receives the tenth feature map and outputs the seventh feature map.
[0152] For example, the schematic diagram of the discrete cosine perception structure and the perception attention feature extractor is as follows: Fig. 9 As shown. The discrete cosine perception structure includes a first normalization layer, a discrete cosine transform structure, a second normalization layer and a perceptual attention feature extractor connected in series. The first part of the perceptual attention feature extractor consists of a fully connected layer, an activation function, and a random drop layer. The output of the first part passes through a fully connected layer, a Softmax layer, and a fully connected layer, and then a weight value is obtained by a Softmax operation. The weight and the result of multiplying the first part of the current perceptual attention feature extractor output are input into the last part, and the last part consists of a fully connected layer and a random drop layer; ⊕ represents a superposition operation. The ⊕ after the discrete cosine transform structure represents the superposition of the third feature map and the fourth feature map, and the ⊕ after the perceptual attention feature extractor represents the seventh feature map and superposition with the fifth feature map.
[0153] In this embodiment, a discrete cosine perception structure is obtained by combining a discrete cosine transform structure with a perceptual attention feature extractor. Through the perceptual attention feature extractor, the input features can be weighted, and different weights are assigned to each feature according to its importance, so that the model pays more attention to the features with the greatest impact, improving the model's representation ability and recommendation accuracy. By analyzing the weights obtained by the perceptual attention feature extractor, the model's prediction process and recommendation results can be better understood, providing guidance for subsequent model optimization and improvement.
[0154] Step S605, flatten the output of the discrete cosine perception layer and pass it through a fully connected layer to obtain the probability that the user is interested in each knowledge module, and then obtain the predicted demand probability sequence.
[0155] It should be noted that the eight discrete cosine perception structures consist of four layers, two in each layer. It is understandable that other numbers of discrete cosine perception structures can also achieve the purpose, but after experiments and referring to the number of layers of some classic deep learning models, the eight discrete cosine perception structures have better prediction accuracy.
[0156] In some embodiments, the eighth feature map output by the last discrete cosine perception structure in the discrete cosine perception layer is input into the fully connected layer as the second feature map to obtain the probability that the user is interested in each knowledge module, thereby obtaining a predicted demand probability sequence.
[0157] In this embodiment, the discrete cosine transform structure converts the input to the frequency domain through discrete cosine transform, so that the network can extract features in the frequency domain to discover higher-order feature information of the input features. The acquired high-order feature information is then extracted through the perceptual attention feature extractor. By extracting features through such a complex transformation, the actual results can be predicted more accurately.
[0158] Step S606: recommend sports knowledge to the user based on the predicted demand probability sequence.
[0159] In this embodiment, the knowledge recommendation model is used to filter out the most relevant and useful content to the user from a large amount of information according to the user's personalized needs and behavior patterns, so as to provide personalized recommendation services.
[0160] See also Fig.10 The present application also provides a knowledge recommendation device, which can implement the above-mentioned knowledge recommendation method, and the device includes:
[0161] The log acquisition module 1001 is used to acquire log information;
[0162] A matrix conversion module 1002 is used to convert log information into an information matrix through one-hot encoding, and input the information matrix into a knowledge recommendation model;
[0163] A sequence output module 1003 is used to output a predicted demand probability sequence through a knowledge recommendation model;
[0164] The knowledge generation module 1004 is used to generate recommended knowledge according to the predicted demand probability sequence.
[0165] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0166] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned knowledge recommendation method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.
[0167] It can be understood that the contents of the above method embodiments are all applicable to the present device embodiments, the functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0168] See also Fig.11 , Fig.11 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:
[0169] The processor 1101 may be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application;
[0170] The memory 1102 may be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1102 may store an operating system and other application programs. When the technical solution provided in the embodiment of this specification is implemented by software or firmware, the relevant program code is stored in the memory 1102, and the processor 1101 calls and executes the knowledge recommendation method of the embodiment of this application;
[0171] Input / output interface 1103, used to implement information input and output;
[0172] The communication interface 1104 is used to realize the communication interaction between the device and other devices. The communication can be realized through a wired manner (such as USB, network cable, etc.) or a wireless manner (such as mobile network, WI FI, Bluetooth, etc.);
[0173] A bus 1105 that transmits information between various components of the device (e.g., the processor 1101, the memory 1102, the input / output interface 1103, and the communication interface 1104);
[0174] The processor 1101 , the memory 1102 , the input / output interface 1103 and the communication interface 1104 are connected to each other in communication within the device via the bus 1105 .
[0175] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned knowledge recommendation method is implemented.
[0176] It can be understood that the contents of the above method embodiments are all applicable to the present storage medium embodiments, the functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0177] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0178] The knowledge recommendation method, knowledge recommendation device, electronic device and storage medium provided in the embodiments of the present application help to understand user needs and preferences by obtaining log information; convert log information into an information matrix through one-hot encoding, and input the information matrix into a knowledge recommendation model, which helps the model understand the diversity of user behavior and thus generate more accurate recommendations; output a predicted demand probability sequence through the knowledge recommendation model; generate recommended knowledge based on the predicted demand probability sequence to achieve personalized knowledge recommendation, thereby improving the efficiency and accuracy of knowledge recommendation and enhancing user experience.
[0179] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
[0180] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0181] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0182] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.
[0183] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0184] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0185] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0186] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0187] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0188] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.
[0189] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.
Claims
1. A knowledge recommendation method, characterized in that: The method comprises the following steps: Get log information; Convert the log information into an information matrix by one-hot encoding, and input the information matrix into a knowledge recommendation model; Outputting a predicted demand probability sequence through the knowledge recommendation model; Generate recommended knowledge according to the predicted demand probability sequence.
2. The method according to claim 1, characterized in that The obtaining of log information includes: In response to the first instruction, obtaining log authorization information; If the log authorization information includes that the user has authorized the log information, the log information is obtained and entered.
3. The method according to claim 1, characterized in that Outputting a predicted demand probability sequence through the knowledge recommendation model includes: Obtaining a number of predicted demand probabilities through the knowledge recommendation model, wherein the predicted demand probabilities include knowledge module identifiers and predicted probabilities; The predicted demand probabilities are arranged in descending order according to the predicted probabilities to obtain a predicted demand probability sequence.
4. The method according to claim 1, characterized in that: The converting the log information into an information matrix by one-hot encoding includes: Obtain the module encoding of the knowledge module through one-hot encoding; Constructing a two-dimensional matrix according to the module code and the log information; The two-dimensional matrix is converted into a three-dimensional matrix to obtain an information matrix.
5. The method according to claim 4, characterized in that The log information includes a plurality of click logs, the click log includes a knowledge module identifier, a total number of clicks corresponding to the knowledge module, and a visit duration corresponding to the knowledge module, the knowledge module identifier corresponds to the module code, and constructing a two-dimensional matrix according to the module code and the log information includes: Generate a one-dimensional matrix corresponding to each click log according to the module code corresponding to the knowledge module identifier, the access duration corresponding to the knowledge module, and the total number of clicks corresponding to the knowledge module; The one-dimensional matrices are combined to obtain a two-dimensional matrix.
6. The method according to claim 1, characterized in that The method also includes the step of training a knowledge recommendation model; The training knowledge recommendation model includes: Receive a log information sample of a sample user, wherein the log information sample includes at least the number of clicks of the sample user to access each knowledge module and the access duration of each click; Generate a predicted demand probability sequence of sample users for each knowledge module based on the log information sample through the knowledge recommendation model to be trained; The knowledge recommendation model is trained according to the predicted demand probability sequence and the real demand probability sequence of the log information sample. When the error between the predicted demand probability sequence and the real demand probability sequence is within a preset range, the trained knowledge recommendation model is obtained.
7. The method according to claim 1, characterized in that The knowledge recommendation model includes a serially connected input embedding layer, a discrete cosine perception layer, and a first fully connected layer. Outputting a predicted demand probability sequence through the knowledge recommendation model includes: Receiving the information matrix through the input embedding layer, generating a first feature map, and inputting the first feature map into the discrete cosine perception layer; Convert the first feature map to the frequency domain through the discrete cosine perception layer to obtain a second feature map, and input the second feature map into the first fully connected layer; The second feature map is received through the first fully connected layer, and a predicted demand probability sequence is output.
8. A knowledge recommendation device, characterized in that: The device comprises: Log acquisition module, used to obtain log information; A matrix conversion module, used for converting the log information into an information matrix through one-hot encoding, and inputting the information matrix into a knowledge recommendation model; A sequence output module, used to output a predicted demand probability sequence through the knowledge recommendation model; The knowledge generation module is used to generate recommended knowledge according to the predicted demand probability sequence.
9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.