Timing sequence correlation recommendation method based on fine tuning large language model
Through fine-tuning and sample enhancement of the large language model, the problem of insufficient cold start and interpretability of the existing recommendation system is solved, and timing-related recommendations based on the large language model are realized, which improves the accuracy and user experience of the recommendation system.
Patent Information
- Application Number
- CN202510185631.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-20
- Publication Date
- 2025-07-04
AI Technical Summary
The existing recommendation systems have shortcomings in cold start problems, human-computer interaction and interpretability, and have failed to effectively utilize the world knowledge and reasoning capabilities of large language models.
By preparing the recommended task dataset, cleaning and correlating data, mapping user ratings into emotional preferences, using tail method to divide training and test sets, sample enhancement, and fine-tuning large language models using LORA technology to build model instructions to improve recommendation capabilities.
It improves the interactivity and interpretability of the recommendation system, and uses the extensive world knowledge and reasoning capabilities of the large language model to achieve more accurate product recommendations.
Smart Images

Figure CN120256715A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of information retrieval, and particularly relates to a time-series related recommendation method based on a fine-tuned large language model for recommending products that a user is interested in according to the user's personal information, product information, and the user's historical consumption records. Background Art
[0002] In the context of information explosion, recommendation systems are widely used in e-commerce, short videos, information retrieval and other fields, which can quickly and accurately help us obtain target information. The recommendation system recommends products that the user is interested in according to the user information, product information, and the interaction information between the user and the product. After the development of technologies such as content-based methods, collaborative filtering, knowledge graphs, and graph neural networks, the recommendation system has gradually become mature. These methods try to mine known information as much as possible to give recommendations. Therefore, the recommendation ability of existing models is limited by known information, and there are deficiencies in interactivity and user-facing interpretability. Currently, the LLM (Large Language Model) has extensive world knowledge and good reasoning ability, which enables the LLM to show excellent performance in text understanding and text generation, which undoubtedly helps to make up for the deficiencies of existing recommendation models in cold start problems, human-computer interaction, and interpretability. At present, most of the related technologies of existing personalized content recommendation methods and systems enhanced by adaptive large language models are for specific business scenarios, using large language models to assist existing recommendation engines, and their characteristics are to use the semantic understanding ability of large language models to identify user intentions, and do not effectively utilize the world knowledge and reasoning ability of large language models. Summary of the Invention
[0003] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a time-series related recommendation method based on a fine-tuned large language model, which can better achieve the recommendation task through knowledge generalization ability.
[0004] The present invention solves its technical problems through the following technical solutions:
[0005] A time-series related recommendation method based on a fine-tuned large language model, characterized by comprising the following steps:
[0006] Step 1, prepare a recommendation task dataset D, and clean and associate the data of the recommendation task dataset D;
[0007] Step 2, map the user's rating of the item in the task dataset D to the corresponding emotional preference;
[0008] Step 3, use the truncation method to divide the dataset D into a training set D train and a test set D test ;
[0009] Step 4, for the training data Dtrain Perform sample augmentation to generate the sample set S train ;
[0010] Step 5: Use the LORA technique to fine-tune the large language model with the sample set S train ;
[0011] Step 6: Perform sample augmentation on the test set data D test to generate the sample set S test ;
[0012] Step 7: Construct the sample set S test as a model instruction and input it into the large language model, and the output of the large language model is the recommendation result.
[0013] Moreover, the specific steps of preparing the recommendation task dataset D and cleaning and associating the data in step 1 are as follows:
[0014] Step 1.1: Filter the dataset D to retain only the user, item, rating, and timestamp information in the dataset.
[0015] Moreover, the specific steps of mapping the user's rating of an item to the corresponding sentiment preference in step 2 are as follows:
[0016] Step 2.1: Convert the user ratings (1-5 or 1-10) corresponding to the task dataset D into a binary classification of "like" and "dislike". The specific process is as follows: Convert the rating (rating) into a binary classification problem. By setting a threshold, convert the rating rating into a binary classification {"like", "dislike"}. The threshold t = int(max(ratings) / 2)+2, where ratings is the set of all ratings in the dataset. If rating≥t, then rating = "like"; otherwise, rating = "dislike".
[0017] Moreover, the specific steps of using the truncation method to divide the task dataset D into the training set D train and the test set D test are as follows:
[0018] Step 3.1: Sort the historical interaction records of user u in ascending order of timestamp as h u ;
[0019] Step 3.2: Divide the historical record h u into u train and u test in a ratio of 4:1, and satisfy h u = u train ∪u test ,
[0020] Among them, u train represents the training data of user u, and u test represents the test data of user u;
[0021] Then, respectively merge u train and u test into D train and D test ;
[0022] Step 3.3: Repeat Steps 3.1 and 3.2 until all users have completed the division, and finally obtain D train and D test ;
[0023] Satisfy D = D train ∪D test ,
[0024] Moreover, the specific steps for the sample augmentation of the training data D train to generate the sample set S train are as follows:
[0025] Step 4.1: Obtain the historical interaction information u train of user u from D train ={r1, r2,..., r m}, and use the sliding window method with a window length of l and a step size of s for training sample augmentation. Finally, u train will be cut into several samples, and the process is as follows: Assume l = 2, s = 1. For the sequence u train ={r1, r2,..., r m}, then there are using r1 and r2 to predict r3, using r2, r3 to predict r4, until using r m-2 and r m-1 to predict r m , and finally obtain the augmented sample set u train’ ={[r1, r2, r3], [r2, r3, r4],..., [r m-2 , r m-1 , r m}; For a user interaction record of length m, after being processed by the sliding window strategy with a window length of l and a step size of s, (m - (l + 1)) / s + 1 training samples will be generated; To avoid wasting historical interaction information, each interaction information r x needs to be used for training sample generation, so s < l + 1 must be satisfied;
[0026] Step 4.2: Merge u train’ into S train ;
[0027] Step 4.3: Repeat steps 4.1 and 4.2 until the historical interaction information of all users is completed for sample enhancement, and finally obtain the sample enhancement set S train 。
[0028] Moreover, in step 5, the sample set S is utilized with the LORA technology train The specific steps for fine-tuning the large language model are as follows:
[0029] Step 5.1: Construct the prompting content using the Input, Instruction, Output structure. This content is presented as a text description that includes input information, instruction requirements for the large model, and output results, and interact with the large model through prompting;
[0030] Step 5.2: Select an open-source large language model, such as LLaMA2-7B, use the prompting formed in step 5.1 as the supervised training sample, and fine-tune the large language model using the LORA method.
[0031] Moreover, in step 6, the test set data D test is subjected to sample enhancement to generate the sample set S test The specific steps are as follows:
[0032] Step 6.1: Obtain the historical interaction information u of user u from D test ={r test ,…,r m+1 ,…,r n}, and adopt a sliding window method with a window length of l and a step size of s for training sample enhancement. Eventually, u test will be cut into several samples, and the process is as follows: Assume l = 2, s = 1. For the sequence u test ={r m+1 ,…,r n}, then there is using r m+1 and r m+2 to predict r m+3 , using r m+2 , r m+3 to predict r m+4 , until using r n-2 and r n-1 to predict r n . Finally, obtain the enhanced sample set u test’ ={[r m+1 , r m+2 , r m+3 ,...,[r n-2 , r n-1 , r n}; For a user interaction record of length n - m, after being processed by a sliding window strategy with a length of l and a step size of s, (n - x - (l + 1)) / s + 1 training samples will be generated; to avoid wasting historical information, each interaction information r x' is involved in the generation of training samples, so s < l + 1 needs to be satisfied;
[0033] Step 6.2, Merge u test into S test ;
[0034] Step 6.3, Repeat Steps 6.1 and 6.2 until the sample enhancement of the historical interaction information of all users is completed, and finally obtain the sample enhancement set S test .
[0035] Moreover, Step 7 constructs the sample set S test into a model instruction and inputs it into the large language model. The specific steps for the output of the large language model to be the recommended result are as follows:
[0036] Step 7.1, Construct the instruction content, and use the Input and Instruction structures to construct the prompting content. This content is presented as a text description, which includes input information and requirements for the large model instructions, and completes the interaction with the large model through the instruction prompt;
[0037] Step 7.2, Use the fine-tuned large language model as the recommendation engine, input the instruction generated in Step 7.1 into the large language model, and its output becomes the final result;
[0038] Step 7.3, Compare the output result of Step 7.2 with the test samples generated in Step 6 to evaluate the recommendation effect.
[0039] The beneficial effects of the present invention are as follows:
[0040] 1. The time-series related recommendation method based on the fine-tuned large language model of the present invention recommends products that users are interested in, avoids the limitation of the recommendation ability of existing models to known information, and improves the interactivity and user-oriented interpretability.
[0041] 2. The time-series related recommendation method based on the fine-tuned large language model of the present invention utilizes the extensive world knowledge and powerful reasoning ability of the large language model. Regard the fine-tuned large language model as the recommendation engine, sort the user consumption behaviors according to the time series, convert this sequence into several supervised samples through the sliding window acquisition method, then constrain it into supervised data for fine-tuning through the prompting framework, and finally use the LORA method to fine-tune the target large language model, so that the large language model can obtain the association between the user's previous and subsequent consumption behaviors, thereby improving the recommendation ability of the large language model. Description of the Drawings
[0042] Figure 1 This is the flowchart of the present invention. Detailed implementation manners
[0043] The present invention will be further described in detail below through specific embodiments. The following embodiments are only descriptive and not restrictive, and the protection scope of the present invention cannot be limited thereby.
[0044] A time series-related recommendation method based on fine-tuning a large language model, which includes the following steps:
[0045] Step 1: Prepare the recommendation task dataset D, and clean and associate the recommendation task dataset D;
[0046] 1.1 Filter the dataset D, and only retain the user, item, rating, and timestamp information in the dataset. Associate the user, item, and interaction information in the dataset D, and only retain the user name, the name of the interacted item, the user's evaluation, and the occurrence time of the interaction record. Each interaction is represented by a quadruple R = {userID, itemID, rating, Timestamp}.
[0047] Step 2: Map the user's rating of the item to the corresponding sentiment preference;
[0048] Step 2.1: Convert the user ratings (1-5 points or 1-10 points) corresponding to the task dataset D into a binary classification of "like" and "dislike". The specific process is as follows:
[0049] Convert the user ratings rating (1-5 points or 1-10 points) corresponding to the dataset D into a binary classification of "like" and "dislike", and for purchase behavior, it can be expressed as "yes" and "no". Taking movie ratings as an example, the user's preference for movies is rated from 1 to 5 points. Convert the rating rating into a binary classification problem, and convert the rating rating into a binary classification {"Like", "Dislike"} by setting a threshold. The threshold t = int(max(ratings) / 2)+2, where ratings is the set of all ratings in the dataset. If rating≥t, then rating = "Like", otherwise rating = "Dislike".
[0050] Step 3: Use the tail-taking method to divide the dataset D into a training set D train and a test set D test ;
[0051] Step 3.1: Sort the historical interaction records of user u in ascending order of timestamp as h u ;
[0052] Step 3.2: Divide the historical record h in a ratio of 4:1 into u u and u train such that h test = u u ∪ u train , where u test ,
[0053] represents the training data of user u, and u train represents the test data of user u; test Then merge u
[0054] into D train , and merge u train into D test ; test ;
[0055] Step 3.3: Repeat steps 3.1 and 3.2 until all users have been divided, and finally obtain D train and D test ;
[0056] satisfying D = D train ∪ D test ,
[0057] Step 4: Perform sample augmentation on the training data D train to generate the sample set S train ;
[0058] Step 4.1: Obtain the historical interaction information u of user u from D train = {r1, r2,..., r train}, and use the sliding window method with a window length of l and a step size of s for training sample augmentation. Finally, u m will be cut into several samples, and the process is as follows: Assume l = 2 and s = 1. For the sequence u train = {r1, r2,..., r train}, then there are using r1 and r2 to predict r3, using r2, r3 to predict r4, until using r m and r m-2 to predict r m-1 . Finally, the augmented sample set u m = {[r1, r2, r3], [r2, r3, r4],..., [r train’ , r m-2 , r m-1 , r m}; For a user interaction record of length m, after processing with a sliding window strategy with a window length of l and a step size of s, (m - (l + 1)) / s + 1 training samples will be generated; To avoid wasting historical interaction information, each interaction information r x is used for training sample generation, so s < l + 1 must be satisfied;
[0059] Step 4.2, Merge u train’ into S train ;
[0060] Step 4.3, Repeat steps 4.1 and 4.2 until the historical interaction information of all users is completed for sample enhancement, and finally obtain the sample enhancement set S train .
[0061] Step 5, Use the LORA technology to fine-tune the large language model with the sample set S train ;
[0062] Step 5.1, Use the Input, Instruction, Output structure to construct the prompting content, where Instruction is included in Input, and this content is presented as a text description, which includes input information, instruction requirements for the large model, and output results. Interact with the large model through prompting; Taking the movie recommendation task as an example, the prompting framework is as follows:
[0063] Input: "In chronological order, user name has successively watched the fil-ms_ movie list and provided the respective evaluations of like or dislike . Please judge whether user name likes the movie name . Please output only the results “Like” or “Dislike”."
[0064] Output: likeordislike .
[0065] The final prompting example is as follows:
[0066] Input: "In chronological order, User u has successively watched the films "All Dogs Go to Heaven 2(1996)", "Operation Dumbo Drop(1995)", "Sneakers(1992)", "Disclosure(1994)", "Doom Generation, The(1995)", "Batman Forever(1995)", "Wizard of Oz, The (1939)", "Indiana Jones and the Last Crusade (1989)" and provided the respective evaluations of "Dislike", "Dislike", "Like", "Li ke", "Dislike", "Dislike", "Like", "Like". Please judge whether user u likes the "Young Frankenstein (1974)". Please output only the results "Like" or "Dislik e"."
[0067] Output: "Like".
[0068] Step 5.2: Select an open source large language model, such as LLaMA2-7B, use the prompts formed in step 5.1 as supervised training samples, and use the LORA method to fine-tune the large language model.
[0069] Step 6: Test set data D test Perform sample enhancement to generate sample set S test ;
[0070] Step 6.1, from D test Get historical interaction information u of user u test = {r m+1 ,…,r n}, the training samples are enhanced by sliding windows with a window length of l and a step length of s. test will be cut into several samples, the process is as follows: Assume l = 2, s = 1, for the sequence u test = {r m+1 ,…,r n}, so there is use of r m+1 and r m+2 Prediction m+3, using r m+2 , r m+3 Predict r m+4 , until using r n-2 and r n-1 Predict r n , and finally obtain the enhanced sample set u test’ = {[r m+1 , r m+2 , r m+3 ,..., [r n-2 , r n-1 , r n}; For user interaction records of length n - m, after being processed by a sliding window strategy with a length of l and a step size of s, (n - m - (l + 1)) / s + 1 training samples will be generated; To avoid wasting historical information, each interaction information r x' needs to participate in the generation of training samples, so s < l + 1 must be satisfied;
[0071] Step 6.2, Merge u test into S test ;
[0072] Step 6.3, Repeat Steps 6.1 and 6.2 until the sample enhancement of the historical interaction information of all users is completed, and finally obtain the sample enhancement set S test .
[0073] Step 7, Construct the sample set S test into a model instruction and input it into the large language model, and the output of the large language model is the recommendation result.
[0074] Step 7.1, Construct the instruction content, use the Input, Instruction structure to construct the prompting content, and this content is presented as a text description, which contains input information and instruction requirements for the large model. Complete the interaction with the large model through the instruction prompt; Taking the movie recommendation task as an example, the prompting framework is as follows:
[0075] Input: "In chronological order, user name has successively watched the films_ movie list and provided the respective evaluations of like or dislike . Please judge whether user likes the movie name . Please output only the results “Like” or “Dislike”."
[0076] The final teleprompter example is as follows:
[0077] Input: "In chronological order, User 1 has successively watched the films “Nadja (1994)”, “While You Were Sleeping (1995)”, “Net, The (1995)”, “Last of the Mohicans, The (1992)”, “Homeward Bound: The Incredible Journey (1993)”, “Free Willy (1993)”, “Die Hard 2 (1990)”, “Carlito's Way (1993)” and provided the respective evaluations of “Dislike”, “Like”, “Dislike”, “Like”, “Dislike”, “Dislike”, “Dislike”, “Like”. Please judge whether User 1 likes the “Santa Clause, The (1994)”. Please output only the results “Like” or “Dislike”."
[0078] Step 7.2: Use the fine-tuned large language model as the recommendation engine, and input the samples generated in Step 7.1 into the large language model, and its output becomes the final result;
[0079] Step 7.3: Compare the output result of Step 7.2 with the test samples generated in Step 6 to evaluate the recommendation effect.
[0080] Finally, the method of the present invention is compared with similar recommendation methods. The publicly available datasets MovieLens100k (movies) and Amazon - Book (books) are used as experimental data, and AUC is used as the evaluation metric. In the experiment, the pre - trained model LLaMA2 - 7B open - sourced by Meta is used as the base model by the present invention. From Table 1, it can be obtained that the method of the present invention is significantly superior to the traditional methods in terms of performance. The AUC value of the traditional methods is around 0.5, and its performance is slightly higher than random guessing. The LLM fine - tuned by the method of the present invention has a nearly 20% improvement compared with the traditional model. This shows that the LLM adjusted by the method of the present invention can better achieve the recommendation task through the knowledge generalization ability. In addition, compared with the latest recommendation model TALLRec based on LLM, the method of the present invention is superior in both the Movie dataset and the Book dataset.
[0081] Table 1 Experimental comparison of each model
[0082]
[0083] Although the embodiments and drawings of the present invention are disclosed for illustrative purposes, those skilled in the art can understand that various substitutions, changes, and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. Therefore, the scope of the present invention is not limited to the content disclosed in the embodiments and drawings.
Claims
1. A time-series related recommendation method based on fine-tuning a large language model, characterized in that: It includes the following steps: Step 1: Prepare the recommendation task dataset D, and clean and associate the data in the recommendation task dataset D; Step 2: Map the ratings of users for items in the task dataset D to corresponding sentiment preferences; Step 3: Use the truncation method to divide the dataset D into a training set D train and a test set D test ; Step 4. Perform sample augmentation on the training data D train to generate a sample set S train ; Step 5: Use the LoRA technology to fine-tune the large language model with the sample set S train ; Step 6. Perform sample augmentation on the test set data D test to generate a sample set S test ; Step 7. Construct the sample set S test into a model instruction and input it into the large language model, and the output of the large language model is the recommendation result.
2. The time series-related recommendation method based on fine-tuning a large language model according to claim 1, wherein: The specific steps of preparing the recommendation task dataset D and cleaning and associating the data in the recommendation task dataset D in Step 1 are as follows: Step 1.1: Filter the dataset D, and only retain the user, item, rating, and timestamp information in the dataset.
3. The time-series related recommendation method based on fine-tuning a large language model according to claim 1, characterized in that: The specific steps of mapping the ratings of users for items to corresponding sentiment preferences in Step 2 are as follows: Step 2.1: Convert the user ratings (1-5 points or 1-10 points) corresponding to the task dataset D into a binary classification of "like" and "dislike". The specific process is as follows: Convert the rating into a binary classification problem, and convert the rating into a binary classification {"like", "dislike"} by setting a threshold. The threshold t = int(max(ratings) / 2)+2, where ratings is the set of all ratings in the dataset. If rating ≥ t, then rating = "like", otherwise rating = "dislike".
4. The time series related recommendation method based on fine-tuning a large language model according to claim 1, wherein: In step 3, the task data set D is divided into a training set D train and a test set D test by using the truncation method. The specific steps are as follows: Step 3.
1. Sort the historical interaction records of user u in ascending order of timestamps to obtain h u ; Step 3.2: Divide the historical record h in a ratio of 4:1 u into u train and u test , and satisfy h u = u train ∪ u test , Among them, u train represents the training data of user u, and u test represents the test data of user u; Then, merge u train and u test into D train and D test ; Step 3.
3. Repeat Steps 3.1 and 3.2 until all users have completed the partitioning, and finally obtain D train and D test ; Satisfy D = D train ∪D test , 5. The temporal correlation recommendation method based on fine-tuning a large language model according to claim 1, wherein: The said step 4 performs sample augmentation on the training data D train to generate a sample set S train The specific steps are as follows: Step 4.
1. Obtain the historical interaction information u of user u from D train = {r1, r2, …, r train}, and use a sliding window method with a window length of l and a step size of s to perform training sample enhancement. Finally, u m will be cut into several samples, and the process is as follows: Assume l = 2 and s = 1. For the sequence u train = {r1, r2, …, r train}, then there are using r1 and r2 to predict r3, using r2, r3 to predict r4, until using r m and r m-2 to predict r m-1 , and finally obtain the enhanced sample set u m = {[r1, r2, r3], [r2, r3, r4], …, [r train’ , r m-2 , r m-1 , r m}; For a user interaction record of length m, after being processed by the sliding window strategy with a window length of l and a step size of s, (m - (l + 1)) / s + 1 training samples will be generated; To avoid wasting historical interaction information, each interaction information r x needs to be used for training sample generation, so s < l + 1 must be satisfied; Step 4.2, combine u train’ into S train ; Step 4.
3. Repeat Steps 4.1 and 4.2 until the historical interaction information of all users is completed for sample enhancement, and finally obtain the sample enhancement set S train .
6. The time series related recommendation method based on fine-tuning a large language model according to claim 1, characterized in that: The step 5 uses LORA technology to process the sample set S train The specific steps for fine-tuning the large language model are as follows: Step 5.1: Use the Input, Instruction, Output structure to construct the prompting content, which is presented as a text description. It contains input information, instruction requirements for the large model, and output results, and complete the interaction with the large model through prompting; Step 5.2: Select an open-source large language model, such as LLaMA2-7B, use the prompting formed in Step 5.1 as the supervised training sample, and fine-tune the large language model using the LORA method.
7. The time-series related recommendation method based on fine-tuning a large language model according to claim 1, wherein: The said step 6 performs sample augmentation on the test set data D test to generate a sample set S test The specific steps are as follows: Step 6.
1. Obtain the historical interaction information u of user u from D test ={ test test r m+1 ,…,r n}, and use a sliding window method with a window length of l and a step size of s to perform training sample enhancement. Finally, u test will be cut into several samples, and the process is as follows: Assume l = 2 and s = 1. For the sequence u test ={ test m+1 r n},…,r m+1 and r m+2 to predict r m+3 , use r m+2 , r m+3 to predict r m+4 , and so on until using r n-2 and r n-1 to predict r n . Finally, the enhanced sample set u test’ ={ test’ m+1 [r m+2 , r m+3 , r n-2 ,...,[r n-1 , r n}; For a user interaction record with a length of n - m, after being processed by a sliding window strategy with a length of l and a step size of s, (n - m - (l + 1)) / s + 1 training samples will be generated; To avoid wasting historical information, each interaction information r x' needs to participate in the generation of training samples, so s < l + 1 must be satisfied; Step 6.
2. Merge u test into S test ; Step 6.3: Repeat steps 6.1 and 6.2 until the historical interaction information of all users is completed for sample enhancement, and finally obtain the sample enhancement set S test .
8. The time-series related recommendation method based on fine-tuning a large language model according to claim 1, characterized in that: The above-mentioned step 7 constructs the sample set S test into a model instruction and inputs it into the large language model. The specific steps for the output of the large language model to be the recommended result are as follows: Step 7.1: Construct the instruction content, use the Input, Instruction structure to construct the prompting content, which is presented as a text description. It contains input information and instruction requirements for the large model, and complete the interaction with the large model through instruction prompting; Step 7.2: Use the fine-tuned large language model as the recommendation engine, input the instruction generated in Step 7.1 into the large language model, and its output becomes the final result; Step 7.3: Compare the output result of Step 7.2 with the test sample generated in Step 6 to evaluate the recommendation effect.
Citation Information
Cited By
Large language model driven time series data prediction method
CN121235097A