Product recommendation method and device, electronic equipment, storage medium and program product
By integrating the attention mechanism of users' long-term and short-term interests in product recommendations, combining user base and historical behavior data, more accurate product recommendations are generated, which solves the problem of inaccurate recommendation results in the existing technology and improves the user experience.
Patent Information
- Application Number
- CN202411511911.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-01-14
AI Technical Summary
The prior art fails to accurately understand the user's behavioral interests in product recommendations, resulting in low accuracy of recommendation results and dynamic changes in user interest points over time, making it difficult for existing recommendation technologies to adapt.
By obtaining the query vector of user input content, combining with the product vector database for searching, obtaining user basic data and historical behavior data, and using product recommendation probability prediction model for training, the model's attention mechanism integrates the user's long-term interests and short-term interests to generate more Accurate recommendations.
It improves the relevance and attractiveness of product recommendations, can better fit users' interests on different time scales, and significantly improves the accuracy and user experience of recommendations.
Smart Images

Figure CN119313433A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a product recommendation method, device, electronic device, storage medium and program product. Background Art
[0002] With the development of the Internet, more and more information has begun to spread on the Internet, resulting in serious information overload. The value of information recommendation lies in how to find information that users are interested in from a large amount of information, solve user pain points through precise recommendations, further improve user experience, and then retain users.
[0003] Existing technologies often use large language models to generate descriptions of user preferences based on user information and product information, and then use the descriptions of user preferences as features of the recommendation system. The recommendation system then outputs the user's preference results for products, and accurately recommends products based on the user's preference results for products to meet the data required by the user. However, when performing user recommendation tasks, large language models only understand the user's basic information and provide products related to the user's background, but do not accurately understand the user's behavioral interests, and the user's behavioral interests may change dynamically over time. Therefore, the recommendation results generated by existing recommendation technologies are not very accurate. Summary of the invention
[0004] The present invention provides a product recommendation method, device, electronic device, storage medium and program product, which are used to solve the problem that the recommendation results generated in the prior art are not accurate enough.
[0005] In a first aspect, the present invention provides a product recommendation method, comprising: Get the query vector of the user input; Based on the query vector, searching in a product vector database to obtain a plurality of initial product data; Obtaining basic data and historical behavior data of the user; Based on the multiple initial product data, the basic data and the historical behavior data, a product recommendation probability prediction model is trained to obtain multiple target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining the sample product data with the user's long-term interests and short-term interests; Generate recommended content for each target product data.
[0006] In one embodiment, the product vector database stores a plurality of product vectors; any of the product vectors is obtained by: Get product descriptions of sample products; Performing text preprocessing on the product description to obtain a preprocessed product description; Performing topic consistency detection on multiple sentence pairs in the preprocessed product description to obtain topic similarity of each sentence pair; the sentence pair refers to two sentences in the preprocessed product description that have a continuous relationship; Determine the dynamic similarity threshold for each sentence pair; Based on the topic similarity and dynamic similarity threshold of each sentence pair, the preprocessed product description is divided into blocks to obtain multiple product description blocks; Performing vectorization processing on the multiple product description blocks to obtain multiple vector representations; Aggregation is performed based on the multiple vectors to obtain a product vector of the sample product.
[0007] In one embodiment, the searching in the product vector database based on the query vector to obtain a plurality of initial product data includes: Calculate similarity between the multiple product vectors and the query vector respectively to obtain a similarity value between each product vector and the query vector; The product vector corresponding to the topK with the largest similarity value is determined as the associated product vector; The product structured data of each associated product vector is queried, and the product structured data of each associated product vector is determined as initial product data.
[0008] In one embodiment, the training is performed based on the multiple initial product data, the basic data and the historical behavior data through a product recommendation probability prediction model to obtain multiple target product data, including: Splicing each initial product data with the basic data and the historical behavior data to obtain a plurality of spliced data; Input the multiple spliced data into a product recommendation probability prediction model to obtain a user handling prediction probability corresponding to each initial product data; The initial product data corresponding to the topN users with the highest predicted probability are determined as the target product data.
[0009] In one embodiment, the attention mechanism of the product recommendation probability prediction model is determined in the following manner: Obtain sample user basic data, sample user behavior data, and sample product data; Embedding the sample user basic data, the sample user behavior data, and the sample product data to obtain a user information embedding vector, a user behavior embedding vector, and a product embedding vector; Determining a first attention weight based on the user information embedding vector, the user behavior embedding vector, and the product embedding vector; Determining a second attention weight based on the user information embedding vector, the user behavior embedding vector, the product embedding vector, and a time decay factor; Multiplying the first attention weight and the product embedding vector to obtain long-term interest attention; Multiplying the second attention weight and the product embedding vector to obtain short-term interest attention; The long-term interest attention and the short-term interest attention are integrated to obtain the target attention; Based on the target attention, an attention mechanism of the product recommendation probability prediction model is determined.
[0010] In one embodiment, generating the recommended content for each target product data includes: Get multiple product recommendation templates; Integrate the multiple target product data to obtain a product data set; Performing vectorization processing on the product data set to obtain a product feature vector; Performing vectorization processing on the basic data and the historical behavior data to obtain a user feature vector; Performing vectorization processing on the multiple product recommendation templates respectively to obtain multiple template vectors; Splicing each template vector with the user feature vector, the product feature vector and the query vector to obtain a plurality of spliced vectors; Inputting the multiple concatenated vectors into a template scoring model to obtain a score for each product recommendation template output by the template scoring model; Determine the product recommendation template corresponding to the highest score as the target product recommendation template; Based on the target product recommendation template, recommendation content for each target product data is generated.
[0011] In one embodiment, when generating the recommended content for each target product data based on the target product recommendation template, the following steps are performed for each target product data: Filling the target product recommendation template according to the target product data to obtain a filled target product recommendation template; The filled target product recommendation template is input into the large language model to obtain the recommended content of the target product data output by the large language model.
[0012] In a second aspect, the present invention further provides a product recommendation device, comprising: A first acquisition module, used to acquire a query vector of user input content; A retrieval module, configured to search a product vector database based on the query vector to obtain a plurality of initial product data; A second acquisition module is used to acquire the basic data and historical behavior data of the user; A product recommendation module is used to train a product recommendation probability prediction model based on the multiple initial product data, the basic data and the historical behavior data to obtain multiple target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining the sample product data with the user's long-term interests and short-term interests; The product recommendation content generation module is used to generate recommendation content for each target product data.
[0013] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any of the product recommendation methods described above are implemented.
[0014] In a fourth aspect, the present invention further provides a computer-readable storage medium, comprising a non-transitory computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of any of the product recommendation methods described above are implemented.
[0015] In a fifth aspect, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by the processor, it implements the steps of any of the product recommendation methods described above.
[0016] The product recommendation method, device, electronic device, storage medium and program product provided by the present invention utilize retrieval enhancement generation technology to generate query vectors, and realize rapid matching of user queries and product vectors in a product vector database. Based on the retrieval results, combined with the user's basic data and historical behavior data, the input of the product recommendation probability prediction model is optimized through context enhancement technology. At the same time, since the attention mechanism of the product recommendation probability prediction model integrates the user's short-term interests and long-term interests, it can more accurately capture and reflect the user's interest changes. Therefore, the target product data obtained by analyzing and predicting the product recommendation probability prediction model can better fit the user's interests on different time scales, thereby improving the relevance and attractiveness of the recommendation. Furthermore, according to the accurate product recommendation, the corresponding recommendation content is generated, the accuracy of the product recommendation is improved, and the user experience is significantly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 It is a flow chart of the product recommendation method provided by the present invention.
[0019] Figure 2 It is a schematic diagram of the framework of the product recommendation method provided by the present invention.
[0020] Figure 3 It is a structural schematic diagram of the product recommendation device provided by the present invention.
[0021] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0022] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0023] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, rather than to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described herein.
[0024] Combine the following Figure 1-Figure 4 The product recommendation method, device, electronic device, storage medium and program product provided by the present invention are described.
[0025] It should be noted that the product recommendation method provided in the embodiment of the present invention is implemented based on the product recommendation device. Based on the Retrieval-Augmented Generation (RAG) technology, the performance of the large language model in the product recommendation device is improved by combining retrieval and generation, thereby improving the accuracy of the recommendation and user experience. The embodiment of the present invention takes the product recommendation device as an example to describe the product recommendation method.
[0026] Combination Figure 1 and Figure 2 , Figure 1 is a flow chart of the product recommendation method provided by the present invention, Figure 2 It is a schematic diagram of the framework of the product recommendation method provided by the present invention.
[0027] like Figure 1 As shown, the method includes the following: Step 101: Obtain a query vector of user input content; Step 102: Based on the query vector, search in a product vector database to obtain a plurality of initial product data; Step 103: Obtain the basic data and historical behavior data of the user; Step 104: Based on the multiple initial product data, the basic data and the historical behavior data, a product recommendation probability prediction model is trained to obtain multiple target product data; Step 105: Generate recommended content for each target product data.
[0028] Specifically, when a user needs to search for a desired product, the search requirement can be converted into text content and input into the interactive page provided by the product recommendation device for analysis and processing by the system.
[0029] In step 101, the product recommendation device obtains user input content and needs to convert it into a vector representation so that its vector representation can be used to retrieve matching product vectors in a product vector database.
[0030] Usually, the Embedding model is used to obtain vector representation. The Embedding model can map high-dimensional data to a low-dimensional vector representation while retaining the features and semantic information of the original data. It can be effectively used for similarity calculation between data.
[0031] Therefore, it can be understood that the user input content is input into the Embedding model to obtain the query vector output by the Embedding model.
[0032] In step 102, reference Figure 2 The retrieval stage content in the green box is searched in the product vector database based on the query vector, and multiple related product vectors that are most relevant to the user input content are retrieved. Furthermore, the product structured data of each related product vector is queried and determined as the initial product data.
[0033] In step 103 and step 104, refer to Figure 2The enhanced stage content in the blue box requires obtaining the user's basic data and historical behavior data from the private domain user data set. The user's basic data refers to the information that describes the user's basic characteristics, and the user's historical behavior data refers to the user's activity records on a certain platform or service over a period of time, reflecting the user's interaction patterns, interest preferences, and consumption habits. These data together constitute the user portrait, which can help better understand the user's needs and hobbies, thereby providing more personalized services.
[0034] Furthermore, by utilizing context enhancement technology, both the basic data and the historical behavior data are spliced onto each initial product data to obtain the spliced data corresponding to each initial product data, thereby optimizing the input data of the product recommendation probability prediction model. This enables the product recommendation probability prediction model to more accurately capture the input information, understand the user's interests, and ultimately accurately output the user processing prediction probability corresponding to each initial product data.
[0035] Furthermore, according to the size of the user processing prediction probability corresponding to each initial product data, a plurality of target product data that the user is more interested in is screened out from the plurality of initial product data.
[0036] In step 104, reference Figure 2 The generation stage content in the gray box is based on the user's query content, basic information, historical behavior information and product data. It selects the version that best suits the user from multiple product recommendation templates, generates recommendation content for each target product data through the optimal product recommendation template, and automatically generates marketing language for users to understand the attributes of these target product data, guiding users to apply for the final required products according to their own interests.
[0037] The product recommendation method provided by the present invention utilizes retrieval enhancement generation technology to generate query vectors, and realizes rapid matching of user queries and product vectors in a product vector database. Based on the retrieval results, combined with the user's basic data and historical behavior data, the input of the product recommendation probability prediction model is optimized through context enhancement technology. At the same time, since the attention mechanism of the product recommendation probability prediction model integrates the user's short-term interests and long-term interests, it can more accurately capture and reflect the user's interest changes. Therefore, the target product data obtained by analyzing and predicting the product recommendation probability prediction model can better fit the user's interests on different time scales, improve the relevance and attractiveness of the recommendation, and then generate corresponding recommendation content based on the accurate product recommendation, improve the accuracy of the product recommendation, and significantly improve the user experience.
[0038] From the above content, it can be seen that the retrieval process needs to search in the product vector database according to the query vector. Therefore, it is necessary to obtain sample data from the private domain material set in advance, use natural language processing technology to vectorize the sample data, and obtain product vectors to build a product vector database. Therefore, any of the product vectors is obtained in the following way: Get product descriptions of sample products; Performing text preprocessing on the product description to obtain a preprocessed product description; Performing topic consistency detection on multiple sentence pairs in the preprocessed product description to obtain topic similarity of each sentence pair; the sentence pair refers to two sentences in the preprocessed product description that have a continuous relationship; Determine the dynamic similarity threshold for each sentence pair; Based on the topic similarity and dynamic similarity threshold of each sentence pair, the preprocessed product description is divided into blocks to obtain multiple product description blocks; Performing vectorization processing on the multiple product description blocks to obtain multiple vector representations; Aggregation is performed based on the multiple vectors to obtain a product vector of the sample product.
[0039] Specifically, refer to Figure 2 The data preparation content in the gray box obtains the product description of a sample product from the private domain material set.
[0040] Furthermore, the product description is subjected to text preprocessing to obtain a preprocessed product description.
[0041] In one embodiment, the text preprocessing method may include removing stop words, stemming / part-of-speech restoration, and the like.
[0042] Stop word removal refers to removing frequently occurring words from text data that contribute little to the meaning of the text. These words are usually functional words such as articles, auxiliary verbs, prepositions, conjunctions, etc. in the text. You can use libraries such as NLTK or spaCy to remove common stop words.
[0043] Stemming / part-of-speech restoration: Stemming is to reduce a word to its basic form, usually by removing the changing part at the end of the word. Part-of-speech restoration is to reduce a word to its dictionary form. Both stemming and part-of-speech restoration are intended to reduce the complexity and dimensionality of text data and make text analysis more efficient. Porter Stemming or WordNet Lemmatization can be used for stemming / part-of-speech restoration to reduce vocabulary diversity.
[0044] It should be noted that the product description is usually a paragraph consisting of multiple sentences, so it needs to be divided into blocks, the product description is divided into blocks more intelligently and reasonably, and then vectorized for the blocks. Before block division, it is necessary to perceive the context relationship to decide whether to merge or split the two sentences. For the convenience of description, the two sentences with a continuous relationship in the preprocessed product description are called sentence pairs.
[0045] Furthermore, topic consistency detection is performed on multiple sentence pairs in the preprocessed product description. A topic model (such as LDA) can be used to evaluate the similarity between the current sentence and the previous and next sentences, so as to obtain the topic similarity of each sentence pair.
[0046] Furthermore, the dynamic similarity threshold of each sentence pair is determined, that is, the dynamic similarity threshold between the two sentences, to determine whether the two sentences have the same subject content. If they have the same subject content, they can be merged into one block. If they have different subject contents, they need to be divided into two different blocks.
[0047] It should be noted that the dynamic similarity threshold is a dynamic threshold based on text features. Therefore, for text features, text complexity indicators are introduced, such as sentence length, vocabulary diversity (Type-Token Ratio, TTR) and sentence structure complexity (such as the number of clauses).
[0048] Lexical diversity refers to the ratio of the number of different words in a text to the total number of words. A higher TTR indicates a richer vocabulary. Use a set data structure to store the different words in a text, count their number, and compare it to the total number of words.
[0049] The complexity of sentence structure can be measured by the number of clauses, the number of parallel sentences, etc. Complex sentence structures usually contain multiple clauses and parallel structures. Use a syntactic analysis tool (such as spaCy or NLTK) to parse the sentence and count the number of clauses and parallel sentences.
[0050] Then, the complexity index is defined by the following formula:
[0051] in, represents the complexity index, Indicates the length of the sentence, Indicates vocabulary diversity, Indicates the complexity of sentence structure. , , They are the weights of sentence length, lexical diversity, and sentence structure complexity.
[0052] It should be noted that texts with high complexity can use a lower similarity threshold to achieve more detailed segmentation.
[0053] Furthermore, based on the topic similarity and dynamic similarity threshold of each sentence pair, the preprocessed product description is divided into blocks to obtain a plurality of product description blocks.
[0054] That is to say, a comparison is made based on the topic similarity and the dynamic similarity threshold of each sentence pair. If the topic similarity is greater than or equal to the dynamic similarity threshold, it means that the sentence pair has the same topic content and can be directly merged; if the topic similarity is lower than the dynamic similarity threshold, it means that the sentence pair has different topic content, and the sentences in the context window are checked to determine whether to merge or block based on the actual content. Therefore, by comparing the topic similarity and the dynamic similarity threshold of each sentence pair, it is possible to determine which sentences can be merged and which sentences can be blocked, thereby realizing the block processing of the preprocessed product description and obtaining multiple product description blocks.
[0055] Furthermore, multiple product description blocks can be vectorized using a pre-trained Transformer model (such as RoBERTa or DistilBERT) to obtain the vector representation corresponding to each product description block.
[0056] Furthermore, to aggregate multiple vector representations, a pooling technique (such as average pooling or maximum pooling) can be used to aggregate multiple vectors into an overall vector, that is, to obtain an aggregated vector to represent the entire product description.
[0057] Furthermore, attribute data of the sample product, such as category, price range, etc., is obtained from the private domain material set. By introducing additional features as additional dimensions of the vector, the model's ability to understand the product description can be enhanced, providing a richer and more accurate product feature representation.
[0058] Therefore, based on the attribute data of the sample product, the aggregated vector is represented by vector enhancement to obtain the product vector of the sample product, which is finally used to represent the entire product description.
[0059] The following is an example of product description segmentation and vectorization.
[0060] Product description example: Product name: "Smart watch - health monitoring and notification function"; Product Specific Description: "This smart watch has heart rate monitoring, step counting and message notification functions, suitable for sports enthusiasts.".
[0061] According to the above content, block processing is performed, and the example is as follows: Block 1: Smartwatch-health monitoring; Block 2: Notification function; Block 3: heart rate monitoring, step counting; Block 4: Suitable for sports enthusiasts.
[0062] According to the above content, vectorization processing is performed, and the examples are as follows: Table 1
[0063] Based on the above vectors, aggregation (such as average pooling) is performed to obtain the overall vector representation of the product, as shown in the following table: Table 2
[0064] The embodiment of the present invention implements context-aware chunking technology through topic consistency detection and dynamic adjustment of chunk size, which can process long text descriptions more accurately, ensure the contextual relevance and semantic integrity of chunks, avoid information loss or inaccurate representation, and thus improve the relevance of recommended content. Further, by vectorizing the product description chunks and aggregating them together, the product descriptions can be effectively converted into high-quality vector representations, and a product vector database that supports efficient and effective retrieval can be constructed, which not only improves the semantic expression ability of the vectors, but can also be dynamically adjusted according to context and features to meet the needs of different product types, thereby improving the accuracy and flexibility of product recommendations.
[0065] In some embodiments, based on step 102, the query vector is used to search in a product vector database to obtain a plurality of initial product data, including: Calculate similarity between the multiple product vectors and the query vector respectively to obtain a similarity value between each product vector and the query vector; The product vector corresponding to the topK with the largest similarity value is determined as the associated product vector; The product structured data of each associated product vector is queried, and the product structured data of each associated product vector is determined as initial product data.
[0066] Specifically, the similarity between multiple product vectors and the query vector is calculated respectively to obtain the similarity value between each product vector and the query vector. Efficient vector indexing technology, such as FAISS or Annoy, can be used to calculate the cosine similarity between the query vector and the product vector to achieve fast retrieval of large-scale data sets and quickly locate the product vector most relevant to the user's current needs.
[0067] Further, the multiple similarity values are compared in numerical magnitude to obtain a numerical comparison result, and the multiple similarity values are sorted in descending order according to the numerical comparison result to obtain a sorting result.
[0068] Furthermore, according to the sorting result, the product vectors corresponding to the first K similarity values are determined as associated product vectors, wherein K is set according to the actual situation.
[0069] Furthermore, the product structured data of each associated product vector is queried, and the product structured data of each associated product vector is determined as the initial product data.
[0070] The embodiment of the present invention first uses a simple similarity calculation algorithm to quickly locate the associated product vectors related to the user's current needs, replacing the cumbersome multi-way recall architecture in the traditional recommendation system, significantly reducing redundancy and improving recall efficiency. After the associated product vectors are retrieved, the product structured data of these associated product vectors are used as the initial product data for subsequent recommendation selection, reducing computing resource consumption, thereby significantly improving the efficiency and accuracy of product recommendations.
[0071] In some embodiments, based on step 104, the training is performed based on the multiple initial product data, the basic data and the historical behavior data through a product recommendation probability prediction model to obtain multiple target product data, including: Splicing each initial product data with the basic data and the historical behavior data to obtain a plurality of spliced data; Input the multiple spliced data into a product recommendation probability prediction model to obtain a user handling prediction probability corresponding to each initial product data; The initial product data corresponding to the topN users with the highest predicted probability are determined as the target product data.
[0072] Specifically, each initial product data is spliced with the basic data and the historical behavior data to obtain a plurality of spliced data.
[0073] Furthermore, the multiple spliced data are input into the product recommendation probability prediction model to obtain the user handling prediction probability corresponding to each initial product data.
[0074] Furthermore, the predicted probabilities of handling multiple users are compared numerically to obtain a numerical comparison result, and the predicted probabilities of handling multiple users are sorted according to the numerical comparison result to obtain a sorting result.
[0075] Furthermore, based on the sorting results, the initial product data corresponding to the predicted probabilities of the first N users are determined as the target product data, where N is set according to the actual situation.
[0076] Based on the retrieval results, the embodiment of the present invention combines the user's basic data and historical behavior data and uses context enhancement technology to further optimize the input of the product recommendation probability prediction model. At the same time, the attention mechanism of the product recommendation probability prediction model combines the user's long-term interests and short-term interests, so that the target product data analyzed and predicted by the product recommendation probability prediction model can better fit the user's interests on different time scales, thereby improving the relevance and attractiveness of the recommendation.
[0077] In order to generate more diverse and accurate prediction results for the product recommendation probability prediction model, the long-term and short-term interests of users are comprehensively considered. Starting from the existing attention mechanism, the attention mechanism of the product recommendation probability prediction model is appropriately modified to use different interest time periods. Therefore, the attention mechanism of the product recommendation probability prediction model is determined in the following way: Obtain sample user basic data, sample user behavior data, and sample product data; Embedding the sample user basic data, the sample user behavior data, and the sample product data to obtain a user information embedding vector, a user behavior embedding vector, and a product embedding vector; Determining a first attention weight based on the user information embedding vector, the user behavior embedding vector, and the product embedding vector; Determining a second attention weight based on the user information embedding vector, the user behavior embedding vector, the product embedding vector, and a time decay factor; Multiplying the first attention weight and the product embedding vector to obtain long-term interest attention; Multiplying the second attention weight and the product embedding vector to obtain short-term interest attention; The long-term interest attention and the short-term interest attention are integrated to obtain the target attention; Based on the target attention, an attention mechanism of the product recommendation probability prediction model is determined.
[0078] Specifically, obtain sample user basic data, sample user behavior data, and sample product data, among which the sample user basic data may include information such as the sample user's age, gender, average monthly consumption, etc., the sample user behavior data may include historical behavior data such as historical clicked product names and historical purchased product names, and the sample product data may include product-related data such as amount, discount, product name, number of clicks in the past n days, number of purchases in the past n days, etc.
[0079] Furthermore, the sample user basic data, sample user behavior data and sample product data are embedded and represented respectively, and can also be vectorized using the Transformer model to obtain the corresponding user information embedding vector, user behavior embedding vector and product embedding vector.
[0080] Furthermore, based on the user information embedding vector, the user behavior embedding vector and the product embedding vector, a first attention weight is determined, which can be used to calculate long-term interest attention.
[0081] Therefore, the calculation formula for the first attention weight is as follows:
[0082] Among them, Q represents the user information embedding vector, S represents the user behavior embedding vector, and E represents the product embedding vector. represents the first attention weight; Indicates that the user information embedding vector is weighted using a linear transformation so that the user information embedding vector and the product embedding vector have the same dimension, which is convenient for calculating similarity; Indicates that each element in the sample user behavior data is weighted using a linear transformation, and all weighted elements are summed up, so that the user behavior embedding vector and the product embedding vector have the same dimension, which is also convenient for calculating similarity; Represents the scaling factor. In order to prevent the dot product result from being too large and causing the Softmax function to enter the saturation region, the dot product result is usually divided by ,in is the dimension of the product embedding vector.
[0083] At the same time, based on the user information embedding vector, the user behavior embedding vector, the product embedding vector and the time decay factor, the second attention weight is determined, which can be used to calculate short-term interest attention.
[0084] Therefore, the calculation formula for the second attention weight is as follows:
[0085] Among them, Q represents the user information embedding vector, S represents the user behavior embedding vector, and E represents the product embedding vector. represents the second attention weight; Indicates that the user information embedding vector is weighted using a linear transformation so that the user information embedding vector and the product embedding vector have the same dimension, which is convenient for calculating similarity; Indicates that each element in the sample user behavior data is weighted using a linear transformation, and all weighted elements are summed up, so that the user behavior embedding vector and the product embedding vector have the same dimension, which is also convenient for calculating similarity; Represents the scaling factor. In order to prevent the dot product result from being too large and causing the Softmax function to enter the saturation region, the dot product result is usually divided by ,in is the dimension of the product embedding vector; Represents the time decay factor / time decay function, which is used to emphasize the importance of the user's recent behavior.
[0086] The time decay factor / time decay function can take many forms, but a common form is exponential decay. Assume It is the timestamp of a certain behavior in the user behavior data. is the current time point, and the time decay factor / time decay function can be defined as follows:
[0087] in, is a positive number that controls the speed of time decay; Indicates the time difference from the occurrence of the behavior to the current moment.
[0088] The final attention weight is normalized by Softmax, and the similarity score matrix is converted into a probability distribution through the Softmax function to obtain the corresponding probability weight.
[0089] Furthermore, the first attention weight is multiplied by the product embedding vector to obtain the long-term interest attention.
[0090] At the same time, the second attention weight is multiplied by the product embedding vector to obtain the short-term interest attention.
[0091] Furthermore, the long-term interest attention and the short-term interest attention are integrated to obtain the target attention.
[0092] In one embodiment, a simple linear combination plus dynamic weight adjustment may be used, as shown below:
[0093] in, Indicates target attention, Indicates short-term interest and attention. Indicates long-term interest and attention; and They are the weights of short-term interest attention and long-term interest attention. The weights can be dynamically adjusted through similarity calculation to reflect the user's current interest.
[0094] Similarity calculation: ; Weight calculation:
[0095] .
[0096] Furthermore, based on the target attention calculated in the above manner, the attention mechanism of the product recommendation probability prediction model is determined.
[0097] The embodiment of the present invention designs a short-term interest attention module and a long-term interest attention module, and proposes a fusion module, which effectively combines the user's interests on different time scales, can more accurately capture and reflect the user's interest changes, and provide more personalized recommendations.
[0098] In some embodiments, generating recommended content for each target product data includes: Get multiple product recommendation templates; Integrate the multiple target product data to obtain a product data set; Performing vectorization processing on the product data set to obtain a product feature vector; Performing vectorization processing on the basic data and the historical behavior data to obtain a user feature vector; Performing vectorization processing on the multiple product recommendation templates respectively to obtain multiple template vectors; Splicing each template vector with the user feature vector, the product feature vector and the query vector to obtain a plurality of spliced vectors; Inputting the multiple concatenated vectors into a template scoring model to obtain a score for each product recommendation template output by the template scoring model; Determine the product recommendation template corresponding to the highest score as the target product recommendation template; Based on the target product recommendation template, recommendation content for each target product data is generated.
[0099] Specifically, multiple product recommendation templates are obtained.
[0100] Among them, the product recommendation template is a template content pre-set according to different scenarios, which may include basic templates, situational templates, emotion-driven templates, story-telling templates, etc.
[0101] The basic template is a general recommendation template that is suitable for most scenarios, for example: "Based on your preferences, recommend several [category] products.".
[0102] Situational templates are designed for specific situations, for example: "In this [weather / holiday], recommend suitable [category] products."
[0103] Emotion-driven templates are templates generated based on the user's emotional state, for example: "You are in a good mood today. I recommend some [category] products that will make you happier."
[0104] Storytelling templates are templates that integrate story elements, such as: "Imagine what kind of fun you will experience in [scenario] using this [product]."
[0105] Furthermore, multiple target product data are integrated to obtain a product data set. At the same time, the user's basic data and historical behavior data are also integrated to obtain user feature data.
[0106] Furthermore, the product data set, user feature data, and multiple product recommendation templates are respectively vectorized to obtain product feature vectors, user feature vectors, and multiple template vectors.
[0107] Furthermore, each template vector is concatenated with the user feature vector, the product feature vector and the query vector to obtain multiple concatenated vectors. Assuming there is a template vector T, a user feature vector U, a product feature vector P, and a query vector Q, the final input vector X is: X=[U;P;Q;T], where “;” represents the concatenation operation of the vectors.
[0108] Furthermore, the multiple concatenated vectors are input into a template scoring model to obtain a score for each product recommendation template output by the template scoring model.
[0109] In one embodiment, the architecture of the template scoring model may be a multilayer perceptron (MLP) or other suitable models. The architecture of the template scoring model may include an input layer, a hidden layer, and an output layer. The input layer may receive X as input, the hidden layer may have multiple layers, each layer includes a certain number of neurons, and the activation function may be ReLU, etc. The output layer is a single node, and sigmoid or tanh is used as the activation function to output the score.
[0110] During the training process of the template scoring model, sample user behavior data (clicks, purchases, etc.) are used as supervisory signals, and the model parameters are optimized through the back-propagation algorithm.
[0111] In the evaluation process of the template scoring model, indicators such as AUC, accuracy, and recall are used to evaluate the model performance.
[0112] Through the above method, a pre-trained template scoring model can be obtained, which can be used to score the predefined product recommendation templates according to the basic information, historical behavior data and product data of the current user during the application process, and then select the personalized template for the user.
[0113] Furthermore, the scores of the product recommendation templates are numerically compared to obtain a numerical comparison result, and based on the numerical comparison result, the product recommendation template corresponding to the highest score is determined as the target product recommendation template.
[0114] Furthermore, based on the target product recommendation template, recommendation content for each target product data is generated.
[0115] The embodiment of the present invention constructs a product recommendation template library and a template scoring model, combines user query, user attributes, product attributes and other data, first selects the product recommendation template that best suits the user, and then generates prompt words with personalized characteristics based on the optimal product recommendation template, and then inputs the prompt words with personalized characteristics into the large language model to guide the large language model to generate attractive and persuasive recommendation reasons, thereby enhancing the user experience.
[0116] According to the above content, when generating the recommended content of each target product data based on the target product recommendation template, the following steps are performed for each target product data: Filling the target product recommendation template according to the target product data to obtain a filled target product recommendation template; The filled target product recommendation template is input into the large language model to obtain the recommended content of the target product data output by the large language model.
[0117] Specifically, the target product recommendation template is filled according to the target product data to obtain the filled target product recommendation template. If it is a situational template, it may be necessary to obtain additional relevant data that needs to be supplemented by the template according to actual needs.
[0118] Furthermore, the filled target product recommendation template is used as a prompt word of the large language model and input into the large language model, which generates detailed recommendation content for the target product data. This process can be designed with multiple large language model calls to optimize the retrieved context and generate more accurate recommendation content, providing users with explanatory reasons for recommendations when applying for products.
[0119] The embodiment of the present invention selects a product recommendation template that best suits the user, fills the optimal product recommendation template with the most relevant product data required by the user, generates prompt words with personalized characteristics, and then inputs the prompt words with personalized characteristics into a large language model to guide the large language model to generate attractive and persuasive recommendation reasons, thereby enhancing the user experience.
[0120] The product recommendation device provided by the present invention is described below. The product recommendation device described below and the product recommendation method described above can be referenced to each other.
[0121] Reference Figure 3 , Figure 3 It is a structural schematic diagram of the product recommendation device provided by the present invention.
[0122] The product recommendation device comprises: The first acquisition module 310 is used to acquire a query vector of the user input content.
[0123] The retrieval module 320 is used to search the product vector database based on the query vector to obtain a plurality of initial product data.
[0124] The second acquisition module 330 is used to acquire the basic data and historical behavior data of the user.
[0125] The product recommendation module 340 is used to train a product recommendation probability prediction model based on the multiple initial product data, the basic data and the historical behavior data to obtain multiple target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining sample product data with the user's long-term interests and short-term interests.
[0126] The product recommendation content generation module 350 is used to generate recommendation content for each target product data.
[0127] The product recommendation device provided by the present invention utilizes retrieval enhancement generation technology to generate query vectors, and realizes rapid matching of user queries and product vectors in a product vector database. Based on the retrieval results, combined with the user's basic data and historical behavior data, the input of the product recommendation probability prediction model is optimized through context enhancement technology. At the same time, since the attention mechanism of the product recommendation probability prediction model integrates the user's short-term interests and long-term interests, it can more accurately capture and reflect the user's interest changes. Therefore, the target product data obtained by analyzing and predicting the product recommendation probability prediction model can better fit the user's interests on different time scales, thereby improving the relevance and attractiveness of the recommendation. Furthermore, according to the accurate product recommendation, the corresponding recommendation content is generated, the accuracy of the product recommendation is improved, and the user experience is significantly improved.
[0128] Furthermore, the product recommendation device is also used for: Get product descriptions of sample products; Performing text preprocessing on the product description to obtain a preprocessed product description; Performing topic consistency detection on multiple sentence pairs in the preprocessed product description to obtain topic similarity of each sentence pair; the sentence pair refers to two sentences in the preprocessed product description that have a continuous relationship; Determine the dynamic similarity threshold for each sentence pair; Based on the topic similarity and dynamic similarity threshold of each sentence pair, the preprocessed product description is divided into blocks to obtain multiple product description blocks; Performing vectorization processing on the multiple product description blocks to obtain multiple vector representations; Aggregation is performed based on the multiple vectors to obtain a product vector of the sample product.
[0129] Furthermore, the retrieval module 320 is also used for: Calculate similarity between the multiple product vectors and the query vector respectively to obtain a similarity value between each product vector and the query vector; The product vector corresponding to the topK with the largest similarity value is determined as the associated product vector; The product structured data of each associated product vector is queried, and the product structured data of each associated product vector is determined as initial product data.
[0130] Furthermore, the product recommendation module 340 is also used for: Splicing each initial product data with the basic data and the historical behavior data to obtain a plurality of spliced data; Input the multiple spliced data into a product recommendation probability prediction model to obtain a user handling prediction probability corresponding to each initial product data; The initial product data corresponding to the topN users with the highest predicted probability are determined as the target product data.
[0131] Furthermore, the product recommendation device is also used for: Obtain sample user basic data, sample user behavior data, and sample product data; Embedding the sample user basic data, the sample user behavior data, and the sample product data to obtain a user information embedding vector, a user behavior embedding vector, and a product embedding vector; Determining a first attention weight based on the user information embedding vector, the user behavior embedding vector, and the product embedding vector; Determining a second attention weight based on the user information embedding vector, the user behavior embedding vector, the product embedding vector, and a time decay factor; Multiplying the first attention weight and the product embedding vector to obtain long-term interest attention; Multiplying the second attention weight and the product embedding vector to obtain short-term interest attention; The long-term interest attention and the short-term interest attention are integrated to obtain the target attention; Based on the target attention, an attention mechanism of the product recommendation probability prediction model is determined.
[0132] Furthermore, the product recommendation content generating module 350 is also used for: Get multiple product recommendation templates; Integrate the multiple target product data to obtain a product data set; Performing vectorization processing on the product data set to obtain a product feature vector; Performing vectorization processing on the basic data and the historical behavior data to obtain a user feature vector; Performing vectorization processing on the multiple product recommendation templates respectively to obtain multiple template vectors; Splicing each template vector with the user feature vector, the product feature vector and the query vector to obtain a plurality of spliced vectors; Inputting the multiple concatenated vectors into a template scoring model to obtain a score for each product recommendation template output by the template scoring model; Determine the product recommendation template corresponding to the highest score as the target product recommendation template; Based on the target product recommendation template, recommendation content for each target product data is generated.
[0133] Furthermore, the product recommendation content generating module 350 is also used for: Filling the target product recommendation template according to the target product data to obtain a filled target product recommendation template; The filled target product recommendation template is input into the large language model to obtain the recommended content of the target product data output by the large language model.
[0134] It should be noted that the product recommendation device provided by the present invention can execute the product recommendation method described in any of the above embodiments during specific operation, which will not be elaborated in this embodiment.
[0135] Figure 4 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 communicate with each other through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the product recommendation method, which includes: obtaining a query vector of the user input content; based on the query vector, searching in the product vector database to obtain a plurality of initial product data; obtaining the basic data and historical behavior data of the user; based on the plurality of initial product data, the basic data and the historical behavior data, training through a product recommendation probability prediction model to obtain a plurality of target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining the sample product data with the user's long-term interests and short-term interests; generating the recommended content for each target product data.
[0136] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0137] On the other hand, the present invention also provides a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the product recommendation method provided by the above-mentioned embodiments, and the method includes: obtaining a query vector of user input content; based on the query vector, searching in a product vector database to obtain multiple initial product data; obtaining the basic data and historical behavior data of the user; based on the multiple initial product data, the basic data and the historical behavior data, training through a product recommendation probability prediction model to obtain multiple target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining sample product data with the user's long-term interests and short-term interests; generating recommended content for each target product data.
[0138] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the product recommendation method provided in the above-mentioned embodiments, the method comprising: obtaining a query vector of user input content; based on the query vector, searching in a product vector database to obtain a plurality of initial product data; obtaining the basic data and historical behavior data of the user; based on the plurality of initial product data, the basic data and the historical behavior data, training through a product recommendation probability prediction model to obtain a plurality of target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining sample product data with the user's long-term interests and short-term interests; and generating recommended content for each target product data.
[0139] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0140] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A product recommendation method, characterized in that: include: Get the query vector of the user input; Based on the query vector, searching in a product vector database to obtain a plurality of initial product data; Obtaining basic data and historical behavior data of the user; Based on the multiple initial product data, the basic data and the historical behavior data, a product recommendation probability prediction model is trained to obtain multiple target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining the sample product data with the user's long-term interests and short-term interests; Generate recommended content for each target product data.
2. The product recommendation method according to claim 1, characterized in that: The product vector database stores a plurality of product vectors; any of the product vectors is obtained by: Get product descriptions of sample products; Performing text preprocessing on the product description to obtain a preprocessed product description; Performing topic consistency detection on multiple sentence pairs in the preprocessed product description to obtain topic similarity of each sentence pair; the sentence pair refers to two sentences in the preprocessed product description that have a continuous relationship; Determine the dynamic similarity threshold for each sentence pair; Based on the topic similarity and dynamic similarity threshold of each sentence pair, the preprocessed product description is divided into blocks to obtain multiple product description blocks; Performing vectorization processing on the multiple product description blocks to obtain multiple vector representations; Aggregation is performed based on the multiple vectors to obtain a product vector of the sample product.
3. The product recommendation method according to claim 2, characterized in that: The searching in the product vector database based on the query vector to obtain a plurality of initial product data includes: Calculate similarity between the multiple product vectors and the query vector respectively to obtain a similarity value between each product vector and the query vector; The product vector corresponding to the topK with the largest similarity value is determined as the associated product vector; The product structured data of each associated product vector is queried, and the product structured data of each associated product vector is determined as initial product data.
4. The product recommendation method according to claim 1, characterized in that: The training is performed based on the multiple initial product data, the basic data and the historical behavior data through a product recommendation probability prediction model to obtain multiple target product data, including: Splicing each initial product data with the basic data and the historical behavior data to obtain a plurality of spliced data; Input the multiple spliced data into a product recommendation probability prediction model to obtain a user handling prediction probability corresponding to each initial product data; The initial product data corresponding to the topN users with the highest predicted probability are determined as the target product data.
5. The product recommendation method according to claim 1, characterized in that: The attention mechanism of the product recommendation probability prediction model is determined in the following way: Obtain sample user basic data, sample user behavior data, and sample product data; Embedding the sample user basic data, the sample user behavior data, and the sample product data to obtain a user information embedding vector, a user behavior embedding vector, and a product embedding vector; Determining a first attention weight based on the user information embedding vector, the user behavior embedding vector, and the product embedding vector; Determining a second attention weight based on the user information embedding vector, the user behavior embedding vector, the product embedding vector, and a time decay factor; Multiplying the first attention weight and the product embedding vector to obtain long-term interest attention; Multiplying the second attention weight and the product embedding vector to obtain short-term interest attention; The long-term interest attention and the short-term interest attention are integrated to obtain the target attention; Based on the target attention, an attention mechanism of the product recommendation probability prediction model is determined.
6. The product recommendation method according to any one of claims 1 to 5, characterized in that: The generating of recommendation content for each target product data includes: Get multiple product recommendation templates; Integrate the multiple target product data to obtain a product data set; Performing vectorization processing on the product data set to obtain a product feature vector; Performing vectorization processing on the basic data and the historical behavior data to obtain a user feature vector; Performing vectorization processing on the multiple product recommendation templates respectively to obtain multiple template vectors; Splicing each template vector with the user feature vector, the product feature vector and the query vector to obtain a plurality of spliced vectors; Inputting the multiple concatenated vectors into a template scoring model to obtain a score for each product recommendation template output by the template scoring model; Determine the product recommendation template corresponding to the highest score as the target product recommendation template; Based on the target product recommendation template, recommendation content for each target product data is generated.
7. The product recommendation method according to claim 6, characterized in that: When generating the recommended content for each target product data based on the target product recommendation template, the following steps are performed for each target product data: Filling the target product recommendation template according to the target product data to obtain a filled target product recommendation template; The filled target product recommendation template is input into the large language model to obtain the recommended content of the target product data output by the large language model.
8. A product recommendation device, characterized in that: include: A first acquisition module, used to acquire a query vector of user input content; A retrieval module, configured to search a product vector database based on the query vector to obtain a plurality of initial product data; A second acquisition module is used to acquire the basic data and historical behavior data of the user; A product recommendation module is used to train a product recommendation probability prediction model based on the multiple initial product data, the basic data and the historical behavior data to obtain multiple target product data; the attention mechanism of the product recommendation probability prediction model is determined by combining the sample product data with the user's long-term interests and short-term interests; The product recommendation content generation module is used to generate recommendation content for each target product data.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the product recommendation method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, the computer-readable storage medium comprising a non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the product recommendation method according to any one of claims 1 to 7 are implemented.
11. A computer program product, comprising a computer program, characterized in that: When the computer program is executed by a processor, the steps of the product recommendation method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Military training method and device based on knowledge retrieval enhanced large model, equipment and medium
CN119884329A
Large language model alignment fine tuning method, system and equipment of recommendation system
CN119886255A