Keyword recommendation method, device, electronic device and storage medium
By calculating the user's feature vector matrix and the predicted keyword, the attention matrix is generated, and the target keyword is selected from multiple predicted keywords for recommendation, the problem of failure to recommend keywords based on user characteristics in the prior art is solved, and the accuracy of recommendation and user interest matching are improved.
Patent Information
- Application Number
- CN202111434135.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2041-11-29
AI Technical Summary
The existing Suggestion technology fails to recommend keywords based on the characteristics of different users, resulting in poor recommendation results.
By obtaining the keywords to be queried input by the user, finding multiple corresponding prediction keywords and generating feature vectors, and calculating the attention matrix based on the user's own feature vectors, thereby selecting the target keyword from multiple prediction keywords for recommendation.
It realizes keyword recommendations based on user characteristics, improving the accuracy of recommendations and meeting user interests and preferences.
Smart Images

Figure CN114090894B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data search, and particularly to a keyword recommendation method, apparatus, electronic device, and storage medium. Background Art
[0002] Suggestion (intelligent query keyword suggestion) refers to predicting the keywords that a user hopes to search for and returning them to the user based on the keywords entered by the user in the search box. For example Figure 1 as shown, the keyword entered by the user in the search box is "neural network", and the returned intelligent query keyword suggestions are "neural network algorithm", "neural network model", "three major categories of neural network algorithms", "neural network principle", "neural network engine", etc.
[0003] The inventors found in their research that when the existing Suggestion returns predicted keywords to the user, it only makes predictions based on the search times of each keyword, rather than based on the characteristics of different users. How to recommend keywords for users according to the characteristics of different users has become a technical problem to be solved urgently. Summary of the Invention
[0004] The purpose of the embodiments of this application is to provide a keyword recommendation method, apparatus, electronic device, and storage medium to achieve the recommendation of the keywords that a user hopes to search for according to the characteristics of different users. The specific technical solutions are as follows:
[0005] In the first aspect of the implementation of this application, first, a keyword recommendation method is provided. The method includes:
[0006] Obtain the keyword to be queried input by the user;
[0007] Search for multiple predicted keywords corresponding to the keyword to be queried, and generate feature vectors of the multiple predicted keywords;
[0008] Obtain the feature vector of the user himself / herself, where the feature vector of the user himself / herself is a vector calculated based on the feature vectors of the keywords selected by the user in the historical record;
[0009] Calculate an attention matrix according to the matrix composed of the feature vectors of the multiple predicted keywords and the feature vector of the user himself / herself;
[0010] Select a target keyword from the multiple predicted keywords according to the attention matrix and recommend it to the user.
[0011] Optionally, the calculating an attention matrix according to the matrix composed of the feature vectors of the multiple predicted keywords and the feature vector of the user himself / herself includes:
[0012] Calculate the product of the eigenvector of the user himself and the matrix composed of the eigenvectors of multiple predicted keywords to obtain an attention matrix;
[0013] The step of selecting a target keyword from the multiple predicted keywords according to the attention matrix and recommending it to the user includes:
[0014] Select the top N predicted keywords with the largest corresponding dot product from the multiple predicted keywords according to the attention matrix and recommend them to the user.
[0015] Optionally, the step of calculating the product of the eigenvector of the user himself and the matrix composed of the eigenvectors of multiple predicted keywords to obtain an attention matrix includes:
[0016] Obtain a preset coefficient matrix, where the preset coefficient matrix is a matrix calculated from the keywords selected by the user in the historical record and the eigenvector of the user himself;
[0017] Calculate the product of the coefficient matrix and the matrix composed of the eigenvectors of the predicted keywords, and then multiply it by the eigenvector of the user himself to obtain the attention matrix.
[0018] Optionally, the step of calculating the product of the coefficient matrix and the matrix composed of the eigenvectors of the predicted keywords, and then multiplying it by the eigenvector of the user himself to obtain the attention matrix includes:
[0019] Calculate the attention matrix through the preset formula: A = uWQ T , where Q is the matrix composed of the eigenvectors of the predicted keywords, u is the eigenvector of the user, A is the attention matrix, and W is the preset coefficient matrix.
[0020] Optionally, the step of selecting the top N predicted keywords with the largest corresponding dot product from the multiple predicted keywords according to the attention matrix and recommending them to the user includes:
[0021] Normalize the attention matrix;
[0022] Select the top N predicted keywords with the largest corresponding dot product from the multiple predicted keywords according to the normalized attention matrix and recommend them to the user.
[0023] Optionally, the step of obtaining the eigenvector of the user himself includes:
[0024] Obtain the eigenvectors of multiple keywords selected by the user in the historical record;
[0025] Calculate the average value of the feature vectors of multiple keywords selected by the user to obtain the feature vector of the user himself.
[0026] In the second aspect of the implementation of the present application, a keyword recommendation device is further provided. The device includes:
[0027] A keyword acquisition module, configured to acquire a to-be-query keyword input by a user;
[0028] A vector generation module, configured to find multiple predicted keywords corresponding to the to-be-query keyword and generate feature vectors of the multiple predicted keywords;
[0029] A vector acquisition module, configured to acquire the feature vector of the user himself, where the feature vector of the user himself is a vector calculated according to the feature vectors of the keywords selected by the user in the historical record;
[0030] A matrix calculation module, configured to calculate an attention matrix according to a matrix composed of the feature vectors of the multiple predicted keywords and the feature vector of the user himself;
[0031] A keyword recommendation module, configured to select a target keyword from the multiple predicted keywords according to the attention matrix and recommend it to the user.
[0032] Optionally, the matrix calculation module includes:
[0033] A product calculation sub-module, configured to calculate the product of the feature vector of the user himself and a matrix composed of the feature vectors of the multiple predicted keywords to obtain an attention matrix;
[0034] The keyword recommendation module includes:
[0035] A keyword selection sub-module, configured to select the top N predicted keywords with the largest corresponding dot product from the multiple predicted keywords according to the attention matrix and recommend them to the user.
[0036] Optionally, the product calculation sub-module includes:
[0037] A coefficient matrix acquisition unit, configured to acquire a preset coefficient matrix, where the preset coefficient matrix is a matrix calculated according to the keywords selected by the user in the historical record and the feature vector of the user himself;
[0038] An attention matrix acquisition unit, configured to calculate the product of the coefficient matrix and a matrix composed of the feature vectors of the predicted keywords, and then multiply it by the feature vector of the user himself to obtain the attention matrix.
[0039] Optionally, the attention matrix acquisition unit is specifically configured to calculate the attention matrix through a preset formula: A = uWQ T , where Q is a matrix composed of feature vectors of the predicted keywords, u is the feature vector of the user, A is the attention matrix, and W is a preset coefficient matrix.
[0040] Optionally, the keyword selection sub-module includes:
[0041] A normalization unit for normalizing the attention matrix;
[0042] A predicted keyword selection unit for selecting the top N predicted keywords with the largest corresponding dot product from the multiple predicted keywords according to the normalized attention matrix and recommending them to the user.
[0043] Optionally, the vector acquisition module includes:
[0044] A feature vector acquisition sub-module for acquiring feature vectors of multiple keywords selected by the user in the historical record;
[0045] An average value calculation sub-module for calculating the average value of the feature vectors of the multiple keywords selected by the user to obtain the feature vector of the user himself.
[0046] In another aspect of the implementation of the present application, an electronic device is further provided, including a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus;
[0047] The memory is used to store a computer program;
[0048] The processor, when executing the program stored on the memory, implements any one of the above-mentioned keyword recommendation methods.
[0049] In another aspect of the implementation of the present application, a computer-readable storage medium is further provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements any one of the above-mentioned keyword recommendation methods.
[0050] In another aspect of the implementation of the present application, a computer program product including instructions is further provided. When it runs on a computer, it causes the computer to execute any one of the above-mentioned keyword recommendation methods.
[0051] A keyword recommendation method, apparatus, electronic device, and storage medium provided by an embodiment of the present application obtain a to-be-query keyword input by a user; find a plurality of predicted keywords corresponding to the to-be-query keyword and generate feature vectors of the plurality of predicted keywords; obtain a feature vector of the user himself, where the feature vector of the user himself is a vector calculated based on the feature vectors of the keywords selected by the user in the historical record; calculate an attention matrix according to a matrix composed of the feature vectors of the plurality of predicted keywords and the feature vector of the user himself; and select a target keyword from the plurality of predicted keywords according to the attention matrix and recommend it to the user. An attention matrix can be calculated according to a matrix composed of the feature vector of the user himself and the feature vectors of the plurality of predicted keywords, and a target keyword can be selected from the plurality of predicted keywords according to the attention matrix and recommended to the user, so as to realize the selection and recommendation of the keywords that the user hopes to search according to the characteristics of different users themselves. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art.
[0053] Figure 1 An example diagram of search discovery provided in an embodiment of the present application;
[0054] Figure 2 A flowchart of a keyword recommendation method provided by an embodiment of the present application;
[0055] Figure 3 A flowchart of obtaining a feature vector of the user himself provided by an embodiment of the present application;
[0056] Figure 4 Another flowchart of a keyword recommendation method provided by an embodiment of the present application;
[0057] Figure 5 An example diagram of a keyword recommendation method for search discovery provided by an embodiment of the present application;
[0058] Figure 6 A structural diagram of a keyword recommendation apparatus provided by an embodiment of the present application;
[0059] Figure 7 A structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0060] The following will describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application.
[0061] In order to recommend keywords that a user hopes to search according to the characteristics of different users, in the first aspect of the embodiments of the present application, a keyword recommendation method for search discovery is first provided. The above method includes:
[0062] Obtain the keyword to be queried input by the user;
[0063] Find multiple predicted keywords corresponding to the keyword to be queried, and generate feature vectors of the multiple predicted keywords;
[0064] Obtain the feature vector of the user himself, where the feature vector of the user himself is a vector calculated according to the feature vectors of the keywords selected by the user in the historical record;
[0065] Calculate an attention matrix according to the matrix composed of the feature vectors of the multiple predicted keywords and the feature vector of the user himself;
[0066] Select a target keyword from the multiple predicted keywords according to the attention matrix and recommend it to the user.
[0067] It can be seen that through the method of the embodiments of the present application, an attention matrix can be calculated according to the matrix composed of the feature vector of the user himself and the feature vectors of the multiple predicted keywords, and a target keyword can be selected from the multiple predicted keywords according to the attention matrix and recommended to the user. Since the attention matrix is a matrix calculated according to the feature vectors extracted from the keywords selected by the user in the historical record, the attention matrix can represent the user's interest preference. When recommending keywords through this matrix, the keywords that the user hopes to search can be selected and recommended according to the characteristics of different users themselves.
[0068] Specifically, referring to Figure 2 , Figure 2 is a schematic flowchart of a keyword recommendation method provided by the embodiments of the present application, including:
[0069] Step S21, obtain the keyword to be queried input by the user.
[0070] Among them, the keyword to be queried input by the user can be the keyword in the content that the user actually hopes to search. For example, referring to Figure 1 , when the user hopes to search concepts such as neural network algorithms, neural network models, and neural network principles, only need to input the keyword to be queried "neural network", and through keyword recommendation, neural network algorithms, neural network models, neural network principles, etc. can be found according to the keyword to be queried input by the user and recommended to the user.
[0071] The method of the embodiments of the present application is applied to the backend in the search discovery process. Specifically, the backend can be a server or the like.
[0072] Step S22: Search for multiple predicted keywords corresponding to the keyword to be queried, and generate feature vectors of the multiple predicted keywords.
[0073] In one example, to search for multiple predicted keywords corresponding to the keyword to be queried, the keyword to be queried can be matched with preset keywords to obtain the corresponding multiple predicted keywords. Specifically, the keywords searched by the user can be obtained and saved to form a keyword library. When searching for multiple predicted keywords corresponding to the keyword to be queried, the keyword to be queried is matched with each keyword in the keyword library to obtain multiple predicted keywords.
[0074] In one example, the corresponding relationship between the keyword to be queried and the predicted keywords can be preset in advance. When searching for multiple predicted keywords corresponding to the keyword to be queried, the search can be performed according to this corresponding relationship. For example, it can be preset in advance that neural network, neural network principle, neural network algorithm, and neural network model correspond to each other. When searching for the predicted keywords corresponding to the keyword to be queried: neural network, according to the corresponding relationship, the multiple predicted keywords corresponding to the keyword to be queried can be obtained as: neural network principle, neural network algorithm, and neural network model.
[0075] In the actual use process, to search for multiple predicted keywords corresponding to the keyword to be queried and generate feature vectors of the multiple predicted keywords, the keyword search can be performed through a pre-trained network model, and feature extraction is performed on the found keywords to obtain feature vectors of the multiple predicted keywords. Optionally, to search for multiple predicted keywords corresponding to the keyword to be queried and generate feature vectors of the multiple predicted keywords, the feature vectors of each predicted keyword can also be pre-generated and saved. When searching for multiple predicted keywords corresponding to the keyword to be queried, the feature vectors of the multiple predicted keywords can be obtained through the corresponding relationship between the predicted keywords and the feature vectors of the predicted keywords.
[0076] Step S23: Obtain the feature vector of the user himself / herself.
[0077] Among them, the feature vector of the user himself is a vector calculated based on the feature vectors of the keywords selected by the user in the historical records. In the actual use process, the keywords pre-selected by each user can be recorded and saved, and then for each user, the keywords selected by the user are subjected to feature extraction through a pre-trained feature extraction model to obtain the feature vector of the user himself. For example, when the user selects a certain keyword from the recommended keywords, the selected keyword of the user can be recorded, so that the feature vector of the user himself can be calculated based on the feature vector corresponding to the keyword, and after each user search is completed, the feature vector of the user himself can be updated according to the keywords selected by the user during the current search process. Since in the embodiments of the present application, the feature vector of the user himself is a feature vector calculated through the keywords historically selected by the user, the feature vector of the user himself can represent the interest preference of the user himself.
[0078] Step S24: Calculate an attention matrix based on the matrix composed of the feature vectors of multiple predicted keywords and the feature vector of the user himself.
[0079] Among them, the attention matrix is obtained by constraining the feature vectors of multiple predicted keywords through an attention mechanism based on the feature vector of the user himself. Specifically, the attention matrix includes the dot product of the feature vector of the user himself and the feature vectors of the keywords that each predicted user hopes to search for. By calculating the attention matrix based on the matrix composed of the feature vectors of multiple predicted keywords and the feature vector of the user himself, the matrix composed of the feature vectors of multiple predicted keywords and the feature vector of the user himself can be multiplied to obtain the dot products of the feature vectors of multiple predicted keywords and the feature vector of the user himself, and the attention matrix is composed of these multiple dot products. Among them, each value in the attention matrix corresponds to the dot product of the feature vector of the user himself and the feature vectors of a group of keywords that a predicted user hopes to search for. For example, after multiplying the matrix composed of the feature vectors of N predicted keywords by the feature vector of the user himself, the obtained attention matrix is a 1×N order matrix.
[0080] Step S25: Select a target keyword from multiple predicted keywords according to the attention matrix and recommend it to the user.
[0081] Since each value in the attention matrix is the dot product of the user's own feature vector and the feature vector of the predicted keyword that the user hopes to search for, according to the attention matrix, the top N predicted keywords with the largest corresponding dot product can be selected, that is, the top N predicted keywords with the largest dot product between the corresponding feature vectors and the user's own feature vector can be selected from the predicted keywords that the user hopes to search for. Since in the embodiments of the present application, the user's own feature vector is a feature vector calculated from the keywords previously selected by the user, the user's own feature vector can represent the user's own interest preference. Therefore, by calculating the dot product of the user's own feature vector and the feature vector of the predicted keyword that the user hopes to search for, the larger the obtained dot product, the higher the similarity between the feature vector of the predicted keyword and the user's own feature vector, that is, the more in line with the user's own interest preference the keyword is. Therefore, to select target keywords from multiple predicted keywords and recommend them to the user, the top N with the largest dot product can be selected and recommended to the user.
[0082] It can be seen that through the method of the embodiments of the present application, an attention matrix can be calculated based on the matrix composed of the user's own feature vector and the feature vectors of multiple predicted keywords, and target keywords can be selected from the multiple predicted keywords according to the attention matrix and recommended to the user, so as to realize the selection and recommendation of the keywords that the user hopes to search for based on the feature vectors calculated from the keywords previously selected by different users, so that the recommended keywords meet the user's historical search habits.
[0083] Optionally, referring to Figure 3 , step S23 of obtaining the user's own feature vector includes:
[0084] Step S231, obtaining the feature vectors of multiple keywords selected by the user in the historical record;
[0085] Step S232, calculating the average value of the feature vectors of the multiple keywords selected by the user to obtain the user's own feature vector.
[0086] Among them, to obtain the feature vectors of multiple keywords selected by the user in the historical record, after the user selects a keyword from the target keywords, the keywords selected by the user can be recorded. Then, by performing feature extraction on the keywords selected by the user in the record, the feature vectors of multiple keywords selected by the user in the historical record can be obtained. Specifically, a pre-trained feature extraction model can be used to perform feature extraction on the multiple keywords selected by the user to obtain the feature vectors of the multiple keywords selected by the user.
[0087] Calculate the average value of the feature vectors of multiple keywords selected by the user. The feature vectors of multiple keywords selected by the user can be summed up, and then the summed feature vectors are divided by the number of keywords selected by the user to obtain the average value of the feature vectors of multiple keywords selected by the user. Specifically, before calculating the average value of the feature vectors of multiple keywords selected by the user, the dimensions of the feature vectors of multiple keywords selected by the user can also be unified. In the actual use process, after each user search is completed, the user's own feature vector can be updated according to the keywords selected by the user during this search process. Since in the embodiments of the present application, the user's own feature vector is a feature vector calculated through the keywords selected by the user in the past, therefore, the user's own feature vector can represent the user's own interest preference.
[0088] It can be seen that through the method of the embodiments of the present application, the feature vectors of multiple keywords selected by the user in the historical record can be obtained, the average value of the feature vectors of multiple keywords selected by the user is calculated, and the user's own feature vector is obtained, so that the keywords can be selected and recommended through the user's own feature vector representing the user's own interest preference, making the recommended keywords meet the user's interest preference.
[0089] Optionally, referring to Figure 4 , step S24 calculates the attention matrix according to the matrix composed of the feature vectors of multiple predicted keywords and the user's own feature vector, including:
[0090] Step S241, calculate the product of the user's own feature vector and the matrix composed of the feature vectors of multiple predicted keywords to obtain the attention matrix;
[0091] Step S25 selects the target keyword from multiple predicted keywords for recommendation to the user according to the attention matrix, including:
[0092] Step S251, according to the attention matrix, select the top N predicted keywords with the largest corresponding dot product from multiple predicted keywords for recommendation to the user.
[0093] Optionally, calculating the product of the user's own feature vector and the matrix composed of the feature vectors of multiple predicted keywords to obtain the attention matrix includes: obtaining a preset coefficient matrix, where the preset coefficient matrix is a matrix calculated through the keywords selected by the user in the historical record and the user's own feature vector; calculating the product of the coefficient matrix and the matrix composed of the feature vectors of the predicted keywords, and then multiplying it by the user's own feature vector to obtain the attention matrix.
[0094] Optionally, calculate the product of the coefficient matrix and the matrix composed of the eigenvectors of the predicted keywords, and then multiply it by the eigenvector of the user himself to obtain the attention matrix, including: through the preset formula: A = uWQ T , calculate the attention matrix, where Q is the matrix composed of the eigenvectors of the predicted keywords, u is the eigenvector of the user, A is the attention matrix, and W is the preset coefficient matrix.
[0095] Among them, the preset coefficient matrix is a matrix calculated through the keywords selected by the user in the historical record and the eigenvector of the user himself. By calculating the product of this coefficient matrix and the eigenvector matrix, the eigenvector of the keyword that the predicted user hopes to search can be corrected, so as to facilitate the recommendation of the keyword that the predicted user hopes to search pre-specified. Specifically, the preset coefficient matrix can be calculated by the method of model training. The specific training process can include: obtaining the keywords input by the sample user, the sample target keywords, the keywords selected by the user, and the eigenvector of the sample user himself; predicting the target keywords according to the keywords input by the sample user and the eigenvector of the sample user himself; comparing the predicted target keywords with the keywords selected by the user, and correcting the coefficient matrix according to the comparison result, and re-predicting according to the corrected coefficient matrix until the predicted result includes the keywords selected by the user. At this time, the corrected coefficient matrix is the preset coefficient matrix.
[0096] Optionally, according to the attention matrix, select the top N predicted keywords with the largest corresponding dot product from multiple predicted keywords for recommendation to the user, including: normalizing the attention matrix; according to the normalized attention matrix, select the top N predicted keywords with the largest corresponding dot product from multiple predicted keywords for recommendation to the user.
[0097] Among them, to normalize the attention matrix, the elements in the attention matrix can be summed, and each element in the matrix can be divided by the sum of the calculated elements to obtain the normalized attention matrix. Among them, through the normalized attention matrix, it is convenient to compare each element, so as to select the top N predicted keywords that the user hopes to search with the largest corresponding dot product for recommendation to the user.
[0098] It can be seen that through the method of the embodiment of the present application, the attention matrix can be normalized, so that it is convenient to compare each element, select the top N predicted keywords that the user hopes to search with the largest corresponding dot product for recommendation to the user, and improve the comparison efficiency and recommendation efficiency.
[0099] In order to illustrate the keyword recommendation method for search discovery in the embodiment of the present application, the following will be described in conjunction with specific embodiments. See Figure 5 ,Figure 5 An example diagram of the keyword recommendation method for search discovery provided by the embodiments of this application:
[0100] 1. Obtain the Embedding (feature vector) of the Query (keyword) currently searched by the user, the Query Embedding (keyword feature vector) u;
[0101] 2. Obtain the User Embedding (the feature vector of the user himself) u of the user;
[0102] 3. Obtain the embeddings v of all candidate Query sets that have been successfully trained offline q1 、v q2 、…v qn ;
[0103] 4. Multiply the User Embedding of the user by the embeddings of all Query sets to obtain the attention matrix, A.
[0104] 5. Select the top N Queries with the highest scores through the attention matrix.
[0105] In the second aspect of the embodiments of this application, a keyword recommendation device is provided. See Figure 6 , including:
[0106] A keyword acquisition module 601, configured to acquire the keyword to be queried input by the user;
[0107] A vector generation module 602, configured to find multiple predicted keywords corresponding to the keyword to be queried and generate feature vectors of the multiple predicted keywords;
[0108] A vector acquisition module 603, configured to acquire the feature vector of the user himself, where the feature vector of the user himself is a vector calculated based on the feature vectors of the keywords selected by the user in the historical record;
[0109] A matrix calculation module 604, configured to calculate the attention matrix according to the matrix composed of the feature vectors of the multiple predicted keywords and the feature vector of the user himself;
[0110] A keyword recommendation module 605, configured to select target keywords from the multiple predicted keywords according to the attention matrix and recommend them to the user.
[0111] Optionally, the matrix calculation module 604 includes:
[0112] A product calculation sub-module, configured to calculate the product of the feature vector of the user himself and the matrix composed of the feature vectors of the multiple predicted keywords to obtain the attention matrix;
[0113] The keyword recommendation module 605 includes:
[0114] A keyword selection sub-module, configured to select the top N predicted keywords with the largest corresponding dot product from multiple predicted keywords according to the attention matrix and recommend them to the user.
[0115] Optionally, the product calculation sub-module includes:
[0116] A coefficient matrix acquisition unit, configured to acquire a preset coefficient matrix, where the preset coefficient matrix is a matrix calculated from the keywords selected by the user in the historical record and the feature vector of the user itself;
[0117] An attention matrix acquisition unit, configured to calculate the product of the matrix composed of the coefficient matrix and the feature vector of the predicted keyword, and then multiply it by the feature vector of the user itself to obtain the attention matrix.
[0118] Optionally, the attention matrix acquisition unit is specifically configured to calculate the attention matrix through a preset formula: A = uWQ T , where Q is the matrix composed of the feature vectors of the predicted keywords, u is the feature vector of the user, A is the attention matrix, and W is the preset coefficient matrix.
[0119] Optionally, the keyword selection sub-module includes:
[0120] A normalization unit, configured to normalize the attention matrix;
[0121] A predicted keyword selection unit, configured to select the top N predicted keywords with the largest corresponding dot product from multiple predicted keywords according to the normalized attention matrix and recommend them to the user.
[0122] Optionally, the vector acquisition module 603 includes:
[0123] A feature vector acquisition sub-module, configured to acquire the feature vectors of multiple keywords selected by the user in the historical record;
[0124] An average value calculation sub-module, configured to calculate the average value of the feature vectors of the multiple keywords selected by the user to obtain the feature vector of the user itself.
[0125] It can be seen that through the device of the embodiment of the present application, the attention matrix can be calculated according to the matrix composed of the feature vector of the user itself and the feature vectors of multiple predicted keywords, and the target keyword can be selected from multiple predicted keywords according to the attention matrix and recommended to the user, so as to realize the selection and recommendation of the keywords that the user hopes to search according to the characteristics of different users themselves.
[0126] The embodiment of the present application further provides an electronic device, such as Figure 7 shown, which includes a processor 701, a communication interface 702, a memory 703, and a communication bus 704. Among them, the processor 701, the communication interface 702, and the memory 703 complete communication with each other through the communication bus 704.
[0127] The memory 703 is used to store computer programs;
[0128] When the processor 701 is used to execute the program stored on the memory 703, the following steps are implemented:
[0129] Obtain the keyword to be queried input by the user;
[0130] Find multiple predicted keywords corresponding to the keyword to be queried, and generate feature vectors of the multiple predicted keywords;
[0131] Obtain the feature vector of the user himself, where the feature vector of the user himself is a vector calculated based on the feature vectors of the keywords selected by the user in the historical record;
[0132] Calculate an attention matrix according to the matrix composed of the feature vectors of the multiple predicted keywords and the feature vector of the user himself;
[0133] Select a target keyword from the multiple predicted keywords according to the attention matrix and recommend it to the user.
[0134] The communication bus mentioned in the above terminal may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0135] The communication interface is used for communication between the above terminal and other devices.
[0136] The memory may include a Random Access Memory (RAM), or may also include a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0137] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU for short), a Network Processor (NP for short), etc.; it may also be a Digital Signal Processor (DSP for short), an Application Specific Integrated Circuit (ASIC for short), a Field-Programmable Gate Array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0138] In another embodiment provided by the present application, a computer-readable storage medium is further provided. A computer program is stored in the computer-readable storage medium. When the computer program is executed by a processor, the keyword recommendation method described in any one of the above embodiments is implemented.
[0139] In another embodiment provided by the present application, a computer program product containing instructions is further provided. When it runs on a computer, the computer is made to execute the keyword recommendation method described in any one of the above embodiments.
[0140] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server, data center, etc. that contains one or more integrated available media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a Solid State Disk (SSD)).
[0141] It should be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the said element.
[0142] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the apparatus, electronic device, storage medium and computer program product, since they are basically similar to the method embodiments, the description is relatively simple, and reference can be made to the corresponding parts of the method embodiments for the relevant content.
[0143] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are all included in the protection scope of the present application.
Claims
1. A keyword recommendation method, characterized in that, The method includes: Obtaining a keyword to be queried input by the user; Searching for multiple predicted keywords corresponding to the keyword to be queried, and generating feature vectors of the multiple predicted keywords; Obtaining a feature vector of the user himself, where the feature vector of the user himself is a vector calculated based on the feature vectors of the keywords selected by the user in the historical record, and the feature vector of the user himself represents the user's own interest preference; Obtaining a preset coefficient matrix, where the preset coefficient matrix is a matrix calculated through the keywords selected by the user in the historical record and the feature vector of the user himself; Calculating the product of the matrix composed of the coefficient matrix and the feature vectors of the predicted keywords, and then multiplying it by the feature vector of the user himself to obtain an attention matrix; According to the attention matrix, selecting a target keyword from the multiple predicted keywords to recommend to the user.
2. The method according to claim 1, wherein The step of selecting a target keyword from the multiple predicted keywords to recommend to the user according to the attention matrix includes: According to the attention matrix, selecting the top N predicted keywords with the largest dot product from the multiple predicted keywords to recommend to the user.
3. The method according to claim 2, wherein The step of calculating the product of the matrix composed of the coefficient matrix and the feature vectors of the predicted keywords, and then multiplying it by the feature vector of the user himself to obtain the attention matrix includes: Through the preset formula: A = uWQ T , the attention matrix is calculated, where Q is the matrix composed of the feature vectors of the predicted keywords, u is the feature vector of the user, A is the attention matrix, and W is the preset coefficient matrix.
4. The method according to claim 2, wherein The step of selecting the top N predicted keywords with the largest dot product from the multiple predicted keywords to recommend to the user according to the attention matrix includes: Normalizing the attention matrix; According to the normalized attention matrix, selecting the top N predicted keywords with the largest dot product from the multiple predicted keywords to recommend to the user.
5. The method according to claim 1, characterized in that, The step of obtaining the feature vector of the user himself includes: Obtaining the feature vectors of multiple keywords selected by the user in the historical record; Calculating the average value of the feature vectors of the multiple keywords selected by the user to obtain the feature vector of the user himself.
6. A keyword recommendation device, characterized in that The device includes: A keyword acquisition module for obtaining a keyword to be queried input by the user; A vector generation module for searching for multiple predicted keywords corresponding to the keyword to be queried and generating feature vectors of the multiple predicted keywords; A vector acquisition module for obtaining a feature vector of the user himself, where the feature vector of the user himself is a vector calculated based on the feature vectors of the keywords selected by the user in the historical record, and the feature vector of the user himself represents the user's own interest preference; A matrix calculation module for calculating an attention matrix according to the matrix composed of the feature vectors of the multiple predicted keywords and the feature vector of the user himself; A keyword recommendation module for selecting a target keyword from the multiple predicted keywords to recommend to the user according to the attention matrix; The matrix calculation module includes: A product calculation sub-module for calculating the product of the feature vector of the user himself and the matrix composed of the feature vectors of the multiple predicted keywords to obtain an attention matrix; The product calculation sub-module includes: A coefficient matrix acquisition unit, configured to acquire a preset coefficient matrix, where the preset coefficient matrix is a matrix calculated based on keywords selected by a user in historical records and the user's own feature vector; An attention matrix acquisition unit, configured to calculate the product of the matrix formed by the coefficient matrix and the feature vector of the predicted keyword, and then multiply it by the user's own feature vector to obtain the attention matrix.
7. The device according to claim 6, characterized in that The keyword recommendation module includes: A keyword selection sub-module, configured to recommend the top N predicted keywords with the largest corresponding dot product to the user from the multiple predicted keywords according to the attention matrix.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store computer programs; The processor, when executing the programs stored on the memory, implements the method steps described in any one of claims 1-5.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it implements the method steps described in any one of claims 1-5.
Citation Information
Patent Citations
Query recommendation method and device based on history information
CN109145213A