Semantic recommendation method fusing field self-adaption and user preference weighting
By constructing domain-adaptive training data samples and a user preference weighting mechanism, the accuracy and personalization of semantic recommendation methods are improved, addressing the shortcomings of traditional methods in specific domain recommendations and multi-keyword retrieval, and achieving more accurate recommendation results.
Patent Information
- Application Number
- CN202511564222.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2025-12-02
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Traditional semantic recommendation methods struggle to accurately capture user interests when dealing with massive amounts of data. General models perform poorly in specific domain recommendations and multi-keyword retrieval, and they fail to deeply understand the semantic relationships between keywords, leading to inaccurate search results.
By constructing domain-adaptive training data samples, loading a general text embedding model for domain-adaptive training, generating a weight dictionary based on user preferences, and using vector cosine similarity for semantic similarity ranking, the accuracy and personalization of recommendations are improved.
It supports domain-adaptive training for various data types, enhancing model adaptability and scalability, optimizing training speed and model convergence, and making recommendation results more personalized and interpretable.
Smart Images

Figure CN121052259A_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the fields of natural language processing, transfer learning, and information retrieval technology, specifically relating to a semantic recommendation method that integrates domain adaptation and user preference weighting. Background Technology
[0002] In this era of information overload, the rapid increase in data volume often leaves users feeling overwhelmed by the sheer volume of information. To help users find content they are interested in more effectively, semantic recommendation methods have emerged. These methods aim to provide more personalized and accurate recommendation services by understanding the deeper meaning or intent of the content and the user.
[0003] Traditional semantic recommendation methods often struggle to accurately capture user interests when dealing with massive amounts of data. Furthermore, general-purpose semantic recommendation models often perform poorly when faced with domain-specific recommendation tasks due to a lack of targeted feature extraction and model optimization. In addition, when performing multi-keyword searches, traditional methods are often limited to literal matching and fail to deeply understand the semantic relationships between keywords, leading to inaccurate search results.
[0004] General semantic recommendation methods have significant shortcomings when dealing with big data, domain-specific recommendations, and multi-keyword retrieval. Summary of the Invention
[0005] To overcome the shortcomings of general intelligent recommendation methods in fully mining specific semantic information, this application provides a semantic recommendation method that integrates domain adaptation and user preference weighting. By deeply understanding and mining the semantic information in the data and combining it with user preferences for weighting, the accuracy and personalization of recommendations are improved.
[0006] To achieve the above objectives, this application employs the following technical solution:
[0007] This application presents a semantic recommendation method that integrates domain-adaptive and user preference-weighted approaches, comprising the following steps:
[0008] Step 1: Based on specific terms in a specific domain dataset, construct domain-adaptive training data samples, load a general text embedding model, and perform domain-adaptive training on the general text embedding model to generate a domain-adaptive trained model.
[0009] Step 2: Based on the domain-adaptive training data samples constructed in Step 1, construct a domain-specific evaluation dataset and conduct experimental evaluations of the models before and after domain-adaptive training.
[0010] Step 3: Perform word segmentation and data preprocessing on the text in the specific domain evaluation dataset that the user has selected and excluded, obtain the word frequency information of all words in the text, generate a weight dictionary containing all keywords based on the word frequency information, and output the global weight dictionary and solution library keywords.
[0011] Step 4: When the user inputs a query, extract the keywords from the query and generate a vector representation of the query based on the global weight dictionary;
[0012] Step 5: Perform word segmentation and data preprocessing on the solutions in the solution library, and use a general text embedding model trained adaptively in a specific domain to encode the processing results and generate corresponding text vectors;
[0013] Step 6: Based on the vector representation of the query scheme generated in Step 4 and the text vector generated in Step 5, perform vectorized query in the scheme library, use vector cosine similarity to represent text semantic similarity, and finally sort based on vector cosine similarity to generate a recommendation list.
[0014] A further improvement in this application is that the domain-specific adaptive training in step 1 specifically includes the following steps:
[0015] Step 1.1: Based on specific terms in a specific domain dataset, construct domain-adaptive training data samples. Based on the data richness of specific terms, generate sentence pair samples, labeled sentence pair samples, and sentence triples. Sentence pair samples are two similar sentences. In labeled sentence pair samples, the score represents whether the sentence pairs are similar and the degree of similarity. Sentence triples contain specific terms, positive examples of specific terms, and negative examples of specific terms.
[0016] Step 1.2: Determine the data type of the domain-adaptive training data samples and select the corresponding loss function;
[0017] Step 1.3: Load the domain-adaptive training data samples. Use labeled sentence pair samples as the input data format. Each domain-adaptive training data sample includes a sentence pair sample and a label representing the similarity between the sentence pair samples.
[0018] Step 1.4: Select a training strategy to train the general text embedding model, using the Full Parameters Training strategy during training;
[0019] Step 1.5: Configure model training components. Training tools include decorators, accelerators, and learning schedulers.
[0020] Step 1.6: Load the general text embedding model and start training. Learn how to distinguish between positive and negative samples, generate a loss function, and minimize the loss function to make the embedding vectors generated by the general text embedding model fit specific semantics.
[0021] A further improvement in this application is that, in step 1.2, when the data type of the domain adaptive training data samples is labeled sentence pairs, the difference collaborative similarity loss function is used. Specifically, the calculation process of the difference collaborative similarity loss function is as follows:
[0022] Step 1.2.1: Calculate the cosine similarity matrix. And scale:
[0023]
[0024] in, It's a temperature parameter. It is the first Embed a specific term. It is the first Embedding of positive examples of a specific term;
[0025] Step 1.2.2: Construct a similarity difference matrix and calculate the difference between the similarity of a specific term embedding with positive examples and the similarity with negative examples in the cosine similarity matrix. :
[0026]
[0027] in, and These represent the first and second elements in the similarity difference matrix, respectively. , OK;
[0028] Steps 1, 2, and 3: Calculate the loss using... The function calculates the logarithmic sum of the similarity difference matrix and returns the loss function value:
[0029]
[0030] in, This refers to the batch size.
[0031] A further improvement in this application is as follows: Step 1.5, configuring the model training components, is specifically carried out as follows:
[0032] Step 1.5.1: During training, add decorators to the general text embedding model and automatically adjust the batch size based on memory and computing resources during the training component configuration process;
[0033] Step 1.5.2: Accelerator configuration, using automatic mixed precision training, distributed training, gradient accumulation, and memory optimization to accelerate the training process;
[0034] Step 1.5.3: Optimizer configuration, using the AdamW strategy to update the parameters of the general text embedding model based on the gradient;
[0035] Step 1.5.4, Learning Scheduler Configuration: The learning scheduler is used to adjust the learning rate during training. A cosine learning scheduler is used, where the learning rate gradually decreases from its initial value during training, following a cosine function, as shown in the following formula:
[0036]
[0037] in, The learning rate at the current time step. , These represent the maximum and minimum values of the learning rate, respectively. It is the current time step. This represents the total number of training steps.
[0038] A further improvement in this application is that step 2 specifically includes the following steps:
[0039] Step 2.1: To evaluate the effect of domain-adaptive training, specific terms and texts containing those specific terms are added to the evaluation dataset to form a domain-specific evaluation dataset.
[0040] Step 2.2: Using a domain-specific evaluation dataset, conduct experimental evaluations of the general text embedding model before and after domain-adaptive training, and return the MAP, MRR, NDCG, and RECALL metrics. Here, MAP represents the average precision of the query, MRR represents the average reciprocal of the ranking of the first relevant result, NDCG is the normalized value of the cumulative gain, and RECALL is the recall rate of the solutions in the query results.
[0041] Step 2.3: Use a domain-specific evaluation dataset to visually demonstrate the domain-adaptive training effect.
[0042] A further improvement in this application is that step 3, generating the global weight dictionary, specifically includes the following steps:
[0043] Step 3.1: Based on the user's historical selection records, extract the text selected by the user and the text excluded by the user, perform word segmentation and data preprocessing respectively, and use TF-IDF to count the word frequency information of each word in positive and negative examples;
[0044] Step 3.2: Obtain the weights of words in the selection and elimination schemes based on word frequency information, and then calculate the comprehensive weight based on user preferences:
[0045] For the The sum of the weights for selecting and excluding keywords is:
[0046]
[0047] Among them, when hour, Take 1, Taking -1 means that the sum of the weights is the weights in the selected text minus the weights in the excluded text; when hour, Simultaneously set to 0, meaning the sum of the weights is 0;
[0048] Step 3.3: Normalize the sum of weights and generate a global keyword weight dictionary: when there are a total of When using one keyword, the weight dictionary position is:
[0049]
[0050] in, Representing the The normalized weights of each keyword are calculated as follows:
[0051]
[0052] Step 3.3: When a user adds a new history record, the corresponding word frequency information needs to be updated based on the newly added selection and exclusion schemes, and the global weight dictionary needs to be updated.
[0053] A further improvement in this application is that step 4 generates a vector representation of the query scheme, which specifically includes the following steps: Step 4.1: Output the keywords of the query solution based on the query solution; Step 4.2: Find the weights corresponding to the keywords of the query scheme in the global weight dictionary and generate a weight matrix. : ; in, This represents the number of keywords in the query solution. Step 4.3: Encode the keywords in each query scheme using a domain-specific adaptively trained general text embedding model, generating the corresponding word vector matrix. : ; Step 4.4, Weight Matrix With the corresponding word vector matrix Perform a dot product to obtain a solution vector based on keywords and weights. The calculation formula is as follows: ; in, To query keyword text vectors, For the first The word vectors of each keyword, This is a weight matrix for different keywords. For the first The weight value of each keyword, .
[0054] A further improvement of this application is that step 5 specifically includes the following steps:
[0055] Step 5.1: Perform word segmentation and data preprocessing on the solutions in the solution library to generate word representations of the solutions;
[0056] Step 5.2: Based on the general text embedding model that has been adaptively trained for a specific domain, generate corresponding word vectors for each word representation;
[0057] Step 5.3: Select a pooling strategy to generate sentence and segment vectors based on word vectors.
[0058] A further improvement in this application is that, in step 6, vector cosine similarity is used to represent text semantic similarity, with the formula as follows:
[0059]
[0060] in, This represents the embedding vector of the query scheme. , This represents a vector generated from a specific solution in the solution library. , , They represent the first Feature values in each dimension , Indicates the first The squares of the eigenvalues in each dimension.
[0061] The beneficial effects of this application are:
[0062] This application supports domain-adaptive training driven by multiple data types, and can flexibly select loss functions according to different sample types such as sentence pairs, triples, or labeled sentence pairs, thereby enhancing the adaptability and scalability of model training.
[0063] The training process of this application is significantly optimized. By configuring decorators, accelerators, learning rate schedulers, etc., the training speed and model convergence stability are improved, making it suitable for large-scale domain corpus scenarios.
[0064] This application integrates a user preference weighting mechanism, quantifies users' historical behavior as a basic weight matrix, and dynamically adjusts the contribution of keywords during semantic retrieval, making the recommendation results more personalized, reasonable, and interpretable. Attached Figure Description
[0065] Figure 1 This is a flowchart illustrating the process of this application.
[0066] Figure 2 This is a schematic diagram of the adaptive training process in the field of this application.
[0067] Figure 3 This is a schematic diagram of the weight dictionary generated in this application. Detailed Implementation
[0068] The embodiments of this application will be disclosed below with reference to the drawings. For clarity, many practical details will be described in the following description. However, it should be understood that these practical details should not be used to limit this application. That is, in some embodiments of this application, these practical details are not essential.
[0069] like Figures 1-3 As shown, this application presents a semantic recommendation method that integrates domain adaptation and user preference weighting. Figure 2 As shown, the semantic recommendation method includes the following steps:
[0070] Step 1: Based on specific terms in the domain-specific dataset, construct domain-adaptive training data samples, load a general text embedding model, and perform domain-adaptive training on the general text embedding model to generate a domain-specific adaptively trained model. This domain-specific adaptive training specifically includes the following steps:
[0071] Step 1.1: Based on specific terms in a domain-specific dataset, construct domain-adaptive training data samples. Based on the data richness of the specific terms, generate sentence pair samples, labeled sentence pair samples, and sentence triples. Sentence pair samples consist of two similar sentences. In labeled sentence pair samples, scores represent the similarity and degree of similarity between the sentence pairs. Sentence triples contain a specific term, positive examples of that term, and negative examples. In this embodiment, a specific example of a domain-adaptive training sample is: Sentence pair data samples are:
[0072] {
[0073] "sentence1": "“Panda”",
[0074] "sentence2": "Geely 'Panda'"
[0075] }
[0076] The sample data for sentence triples is as follows:
[0077] {
[0078] text: "“Panda”",
[0079] "text_pos": "Geely "Panda"",
[0080] "text_neg": "panda"
[0081] }
[0082] The sample data for sentence pairs with fractions is as follows:
[0083] {
[0084] "sentence1": "“Panda”",
[0085] "sentence1": "Geely "Panda"",
[0086] "label": 1.0
[0087] }
[0088] Step 1.2: Determine the data type of the domain-adaptive training data samples and select the corresponding loss function. If it is a sentence pair sample, you can choose the sentence pair negative cosine similarity loss function, sentence pair negative softmax contrastive loss function, or sentence pair negative sigmoid contrastive loss function according to your needs; if it is a sentence triple, you can choose the sentence triple negative cosine similarity loss function, sentence triple negative softmax contrastive loss function, or sentence triple negative sigmoid contrastive loss function according to your needs; when inputting labeled sentence pair samples, use the difference collaborative similarity loss function.
[0089] This application uses labeled sentence pairs as samples, therefore employing the difference-based collaborative similarity loss function. Specifically, the calculation process for the difference-based collaborative similarity loss function is as follows:
[0090] Step 1.2.1: Calculate the cosine similarity matrix. And scale:
[0091]
[0092] in, This is a temperature parameter, typically set to 0.01-1. It is the first Embed a specific term. It is the first Embedding of positive examples of a specific term;
[0093] Step 1.2.2: Construct a similarity difference matrix and calculate the difference between the similarity of a specific term embedding with positive examples and the similarity with negative examples (positive examples of other terms) in the cosine similarity matrix. :
[0094]
[0095] in, and These represent the first and second elements in the similarity difference matrix, respectively. , OK;
[0096] Step 1.2.3: Calculate the loss. Use the sum-log function to calculate the logarithmic sum of the similarity difference matrix and return the loss function value.
[0097]
[0098] in, This refers to the batch size.
[0099] Step 1.3: Load the domain-adaptive training data samples. Use labeled sentence pair samples as the input data format. Each domain-adaptive training data sample includes a sentence pair sample and a label representing the similarity between the sentence pair samples.
[0100] Step 1.4: Select a training strategy to train the general text embedding model, using the Full Parameters Training strategy during training;
[0101] Step 1.5: Configure the model training components. Training tools include decorators, accelerators, and learning schedulers. The specific process is as follows:
[0102] Step 1.5.1: During training, add decorators to the general text embedding model. During the training component configuration process, automatically adjust the batch size according to memory and computing resources. Set the initial batch_size to 256. When memory or computing resources are insufficient, the value of batch_size can be automatically reduced.
[0103] Step 1.5.2: Accelerator configuration, using automatic mixed precision training, distributed training, gradient accumulation, and memory optimization to accelerate the training process; Automatic mixed precision refers to using different precision data types simultaneously during training, and this is done automatically, thereby speeding up computation and reducing memory usage; Distributed training distributes training tasks to multiple computing devices for parallel data processing; Gradient accumulation is a technique that simulates the effect of large-batch training. When memory is limited, gradients are calculated on multiple small batches, but the model weights are not updated immediately. The gradients of multiple batches are accumulated until a preset threshold is reached, at which point the accumulated gradients are used to update the model weights; Memory optimization refers to reducing memory usage during training by optimizing data loading and storage methods.
[0104] Step 1.5.3: Optimizer configuration. The AdamW strategy is used to update the parameters of the general text embedding model based on the gradient. The update process is as follows:
[0105] Given the loss function L and model parameters The gradient is:
[0106] Calculate the first moment estimate ( (for hyperparameters)
[0107] Calculate the second moment estimate ( (for hyperparameters)
[0108] Corrected first-order moment estimate:
[0109] Corrected second-moment estimate:
[0110] Weight decay is applied based on preset parameter names: if the parameter name is in the decay parameter group, then... , This is the weight decay coefficient. If the parameter does not need to decay, then...
[0111] Parameter update ( For learning rate, (A small constant added for numerical stability)
[0112]
[0113] Step 1.5.4, Learning Scheduler Configuration: The learning scheduler is used to adjust the learning rate during training, enabling the model to converge quickly in the early stages of training and achieve better performance in the later stages. This application uses a cosine learning scheduler. During training, the learning rate gradually decreases from its initial value, and the change process follows a cosine function, as shown in the following formula:
[0114]
[0115] in, The learning rate at the current time step. , These represent the maximum and minimum values of the learning rate, respectively. It is the current time step. This represents the total number of training steps.
[0116] During training, a cosine learning rate scheduler and a warm-up strategy are combined. Instead of using a high learning rate upfront, a gradually increasing learning rate is provided in the early stages of training. After the warm-up phase, the cosine learning rate scheduler is used for further training. This warm-up phase before formal training makes the model more stable in the early stages, which helps the model converge quickly.
[0117] Step 1.6: Load the general text embedding model and start training. Learn how to distinguish between positive and negative samples, generate a loss function, and minimize the loss function to make the embedding vectors generated by the general text embedding model fit specific semantics.
[0118] Step 2: Based on the domain-adaptive training data samples constructed in Step 1, construct a domain-specific evaluation dataset and conduct experimental evaluations of the model before and after domain-adaptive training. Step 2 specifically includes the following steps:
[0119] Step 2.1: To evaluate the effect of domain-adaptive training, specific terms and texts containing those specific terms are added to the evaluation dataset to form a domain-specific evaluation dataset.
[0120] Step 2.2: Using a domain-specific evaluation dataset, conduct experimental evaluations of the general text embedding model before and after domain-adaptive training, and return the MAP, MRR, NDCG, and RECALL metrics. Here, MAP represents the average precision of the query, MRR represents the average reciprocal of the ranking of the first relevant result, NDCG is the normalized value of the cumulative gain, and RECALL is the recall rate of the solutions in the query results.
[0121] Step 2.3: Use a domain-specific evaluation dataset to visually demonstrate the domain-adaptive training effect. Table 1 shows the similarity results with positive and negative examples before training, and Table 2 shows the similarity results with positive and negative examples after training.
[0122] Table 1
[0123]
[0124] Table 2
[0125]
[0126] As can be seen from Tables 1 and 2, the adaptive training result of this application yields a domain-adaptive model, and the domain-adaptive capability of this model is reflected in Tables 1 and 2.
[0127] Table 3
[0128]
[0129] Table 4
[0130]
[0131] Tables 3 and 4 show the similarity results between the query solution and the solutions in the solution library before and after domain-adaptive training, after inputting the query solution. According to Tables 3 and 4, during the search, keywords for the query solution are first extracted; here, car codes enclosed in double quotes are extracted as keywords. Then, the similarity with solutions in the solution library is calculated.
[0132] Step 3: Perform word segmentation and data preprocessing on the text in the user-selected and excluded domain-specific evaluation datasets to obtain the word frequency information of all words in the text. Based on the word frequency information, generate a weight dictionary containing all keywords, and output the global weight dictionary and the keyword library for the solution. (Appendix) Figure 3 As shown, generating the global weight dictionary specifically includes the following steps:
[0133] Step 3.1: Based on the user's historical selection records, extract the text selected by the user and the text excluded by the user, perform word segmentation and data preprocessing respectively, and use TF-IDF to count the word frequency information of each word in positive and negative examples;
[0134] Step 3.2: Obtain the weights of words in the selection and elimination schemes based on word frequency information, and then calculate the comprehensive weight based on user preferences:
[0135] For the The sum of the weights for selecting and excluding keywords is:
[0136]
[0137] Among them, when hour, Take 1, Taking -1 means that the sum of the weights is the weights in the selected text minus the weights in the excluded text; when hour, Simultaneously set to 0, meaning the sum of the weights is 0;
[0138] Step 3.3: Normalize the sum of weights and generate a global keyword weight dictionary: when there are a total of When using one keyword, the weight dictionary position is:
[0139]
[0140] in, Representing the The normalized weights of each keyword are calculated as follows:
[0141]
[0142] Step 3.3: When a user adds a new history record, the corresponding word frequency information needs to be updated based on the newly added selection and exclusion schemes, and the global weight dictionary needs to be updated.
[0143] Step 4: When the user inputs a query, extract the keywords from the query and generate a vector representation of the query based on the global weight dictionary; Step 4, generating the vector representation of the query, specifically includes the following steps: Step 4.1: Output the keywords of the query solution based on the query solution; Step 4.2: Find the weights corresponding to the keywords of the query scheme in the global weight dictionary and generate a weight matrix. : ; in, This represents the number of keywords in the query solution. Step 4.3: Encode the keywords in each query scheme using a domain-specific adaptively trained general text embedding model, generating the corresponding word vector matrix. : ; Step 4.4, Weight Matrix With the corresponding word vector matrix Perform a dot product to obtain a solution vector based on keywords and weights. The calculation formula is as follows: ; in, To query keyword text vectors, For the first The word vectors of each keyword, This is a weight matrix for different keywords. For the first The weight value of each keyword, .
[0144] Tables 5 and 6 show the recommendation results after extracting keyword text from a query and applying the same and different weights, respectively.
[0145] Table 5. Recommendation results without considering user preferences
[0146]
[0147] Table 6. Recommendation results based on user preferences
[0148]
[0149] As shown in Tables 5 and 6, when users pay more attention to information related to "interior design," the weight of "interior design" increases during recommendation, and the ranking of options related to "interior design" in the returned results rises, better meeting user needs. Table 7 shows the recommendation results before and after domain-adaptive training.
[0150] Table 7
[0151] Step 5: Perform word segmentation and data preprocessing on the solutions in the solution library, and encode the processing results using a domain-specific adaptively trained general text embedding model to generate corresponding text vectors. This specifically includes the following steps:
[0152] Step 5.1: Perform word segmentation and data preprocessing on the solutions in the solution library to generate word representations of the solutions;
[0153] Step 5.2: Based on the general text embedding model that has been adaptively trained for a specific domain, generate corresponding word vectors for each word representation;
[0154] Step 5.3: Select a pooling strategy to generate sentence and segment vectors based on word vectors.
[0155] Step 6: Based on the vector representation of the query scheme generated in Step 4 and the text vector generated in Step 5, perform a vectorized query in the scheme library. Use vector cosine similarity to represent text semantic similarity. Finally, sort the queries based on vector cosine similarity and generate a recommendation list. In this step, vector cosine similarity is used to represent text semantic similarity, and the formula is:
[0156]
[0157] in, This represents the embedding vector of the query scheme. , This represents a vector generated from a specific solution in the solution library. , , They represent the first Feature values in each dimension , Indicates the first The squares of the eigenvalues in each dimension.
[0158] This application proposes a semantic recommendation method that integrates domain adaptation and user preference weighting. The semantic recommendation method first selects an appropriate loss function based on the data type of a specific domain and performs domain-adaptive training on a general pre-trained model, enabling it to accurately capture the deep semantics of professional terms within the domain. On this basis, it further constructs a preference weight matrix by combining users' historical behavior data and weights the search keywords to achieve accurate recommendations that combine domain relevance and personal preference.
[0159] The above description is merely an embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of this application should be included within the scope of the claims of this application.
Claims
1. A semantic recommendation method that integrates domain-adaptive and user preference-weighted approaches, characterized in that: The semantic recommendation method includes the following steps: Step 1: Based on specific terms in a specific domain dataset, construct domain-adaptive training data samples, load a general text embedding model, and perform domain-adaptive training on the general text embedding model to generate a domain-adaptive trained model. Step 2: Based on the domain-adaptive training data samples constructed in Step 1, construct a domain-specific evaluation dataset and conduct experimental evaluations of the models before and after domain-adaptive training. Step 3: Perform word segmentation and data preprocessing on the text in the specific domain evaluation dataset that the user has selected and excluded, obtain the word frequency information of all words in the text, generate a weight dictionary containing all keywords based on the word frequency information, and output the global weight dictionary and solution library keywords. Step 4: When the user inputs a query, extract the keywords from the query and generate a vector representation of the query based on the global weight dictionary; Step 5: Perform word segmentation and data preprocessing on the solutions in the solution library, and use a general text embedding model trained adaptively in a specific domain to encode the processing results and generate corresponding text vectors; Step 6: Based on the vector representation of the query scheme generated in Step 4 and the text vector generated in Step 5, perform vectorized query in the scheme library, use vector cosine similarity to represent text semantic similarity, and finally sort based on vector cosine similarity to generate a recommendation list.
2. The semantic recommendation method that integrates domain adaptation and user preference weighting according to claim 1, characterized in that: Step 1, domain-specific adaptive training, specifically includes the following steps: Step 1.1: Based on specific terms in a specific domain dataset, construct domain-adaptive training data samples. Based on the data richness of specific terms, generate sentence pair samples, labeled sentence pair samples, and sentence triples. Sentence pair samples are two similar sentences. In labeled sentence pair samples, the score represents whether the sentence pairs are similar and the degree of similarity. Sentence triples contain specific terms, positive examples of specific terms, and negative examples of specific terms. Step 1.2: Determine the data type of the domain-adaptive training data samples and select the corresponding loss function; Step 1.3: Load the domain-adaptive training data samples. Use labeled sentence pair samples as the input data format. Each domain-adaptive training data sample includes a sentence pair sample and a label representing the similarity between the sentence pair samples. Step 1.4: Select a training strategy to train the general text embedding model, using a full parameter fine-tuning strategy during training; Step 1.5: Configure the model training components; Step 1.6: Load the general text embedding model and start training. Learn how to distinguish between positive and negative samples, generate a loss function, and minimize the loss function to make the embedding vectors generated by the general text embedding model fit specific semantics.
3. The semantic recommendation method that integrates domain adaptation and user preference weighting according to claim 2, characterized in that: In step 1.2, when the data type of the domain-adaptive training data samples is labeled sentence pairs, the difference collaborative similarity loss function is used. Specifically, the calculation process of the difference collaborative similarity loss function is as follows: Step 1.2.1: Calculate the cosine similarity matrix. And scale: ; in, It's a temperature parameter. It is the first Embed a specific term. It is the first Embedding of positive examples of a specific term; Step 1.2.2: Construct a similarity difference matrix and calculate the difference between the similarity of a specific term embedding with positive examples and the similarity with negative examples in the cosine similarity matrix. : ; in, and These represent the first and second elements in the similarity difference matrix, respectively. , OK; Steps 1, 2, and 3: Calculate the loss using... The function calculates the logarithmic sum of the similarity difference matrix and returns the loss function value: ; in, This refers to the batch size.
4. The semantic recommendation method that integrates domain adaptation and user preference weighting according to claim 2, characterized in that: In step 1.5, the training tools include decorators, accelerators, and learning schedulers. Specifically, configuring the model training components includes: Step 1.5.1: During training, add decorators to the general text embedding model and automatically adjust the batch size based on memory and computing resources during the training component configuration process; Step 1.5.2: Accelerator configuration, using automatic mixed precision training, distributed training, gradient accumulation, and memory optimization to accelerate the training process; Step 1.5.3: Optimizer configuration, using the AdamW strategy to update the parameters of the general text embedding model based on the gradient; Step 1.5.4, Learning Scheduler Configuration: The learning scheduler is used to adjust the learning rate during training. A cosine learning scheduler is used, where the learning rate gradually decreases from its initial value during training, following a cosine function, as shown in the following formula: ; in, The learning rate at the current time step. , These represent the maximum and minimum values of the learning rate, respectively. It is the current time step. This represents the total number of training steps.
5. The semantic recommendation method that integrates domain adaptation and user preference weighting according to claim 1, characterized in that: Step 3, generating the global weight dictionary, specifically includes the following steps: Step 3.1: Based on the user's historical selection records, extract the text selected by the user and the text excluded by the user, perform word segmentation and data preprocessing respectively, and use TF-IDF to count the word frequency information of each word in positive and negative examples; Step 3.2: Obtain the weights of words in the selection and elimination schemes based on word frequency information, and then calculate the comprehensive weight based on user preferences: For the The sum of the weights for selecting and excluding keywords is: ; Among them, when hour, Take 1, Taking -1 means that the sum of the weights is the weights in the selected text minus the weights in the excluded text; when hour, Simultaneously set to 0, meaning the sum of the weights is 0; Step 3.3: Normalize the sum of weights and generate a global keyword weight dictionary: when there are a total of When using one keyword, the weight dictionary position is: ; in, Representing the The normalized weights of each keyword are calculated as follows: ; Step 3.3: When a user adds a new history record, the corresponding word frequency information needs to be updated based on the newly added selection and exclusion schemes, and the global weight dictionary needs to be updated.
6. The semantic recommendation method that integrates domain adaptation and user preference weighting according to claim 1, characterized in that: Step 4 generates a vector representation of the query solution, which includes the following steps: Step 4.1: Output the keywords of the query solution based on the query solution; Step 4.2: Find the weights corresponding to the keywords of the query scheme in the global weight dictionary and generate a weight matrix. : ; in, This represents the number of keywords in the query solution. Step 4.3: Encode the keywords in each query scheme using a domain-specific adaptively trained general text embedding model, generating the corresponding word vector matrix. : ; Step 4.4, Weight Matrix With the corresponding word vector matrix Perform a dot product to obtain a solution vector based on keywords and weights. The calculation formula is as follows: ; in, To query keyword text vectors, For the first The word vectors of each keyword, This is a weight matrix for different keywords. For the first The weight value of each keyword, .
Citation Information
Patent Citations
Knowledge graph convolutional network personalized recommendation method and system based on emotion perception
CN118885601A
Knowledge-enhanced large model data analysis agent visualization method
CN119226387A
Intelligent scheme recommendation method based on semantic matching
CN119961508A