Method and model for recommending care suggestions based on knowledge graph and graph attention mechanism
By introducing knowledge graphs and graph attention mechanisms into the care recommendation system, the problem of insufficient personalization and professionalization of care solutions in the existing technology has been solved, and more accurate and personalized care recommendations have been achieved, which has promoted the intelligent development of the care industry.
Patent Information
- Application Number
- CN202411738131.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-21
AI Technical Summary
The prior art provides care programs for dementia elderly people, inadequate levels of personalization and specialization, cannot meet the specific needs of different individuals, and shows limitations when dealing with complex care scenarios.
Using a recommendation method based on knowledge graph and graph attention mechanism, we construct a knowledge graph and optimize node vector representation by integrating Word2Vec, BERT sentence representation, graph attention mechanism and dual objective function to improve the personalization and accuracy of recommendations.
It improves the personalization and accuracy of the care plan for dementia elderly people, can more effectively understand the semantic relationship of care problems, generate more reasonable care suggestions, meet the diversified needs of the elderly, and promote the intelligent development of the care industry.
Smart Images

Figure CN119673403A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and model for recommending care suggestions based on a knowledge graph and a graph attention mechanism. Background Art
[0002] As the global aging population intensifies, the care needs of the disabled and demented elderly population are growing. Although the existing care programs have a certain research basis in theory, including care cases, elderly care guidelines, and expert experience, there are still many deficiencies in practical application. These deficiencies are mainly reflected in the low degree of personalization and specialization of care measures, which makes it impossible to meet the specific needs of different individuals.
[0003] At present, there are some related invention patents and research results. For example, patent CN115905559B proposes a method based on rule matching and threshold setting to obtain care measures, but the applicability and flexibility of its method still need to be improved. At the same time, patent CN110648737B attempts to determine the level of care by displaying and collecting information through computers by setting evaluation questions and answer scores. Although it provides a coarse-grained care plan, it lacks an in-depth understanding of specific care issues.
[0004] In terms of the application of knowledge graphs, the paper "Design and Implementation of an Automatic Question-Answering System Based on Dementia Care Knowledge Graph" uses the AC automaton multi-pattern matching method to build a question-answering system, but this method often relies on predefined dictionaries and cannot effectively handle words that do not exist in the dictionary. Therefore, existing technologies often show limitations when dealing with complex care scenarios.
[0005] In the research of recommendation algorithms, invention patent CN117831703A uses a graph neural network-based method to model the care data of disabled elderly people, and improves the ability to extract global information of samples through a bipartite graph. In addition, the care plan recommendation method through multi-feature learning also provides a certain reference for the generation of personalized care plans. However, the data of this invention is based on cases of disabled elderly people and does not cover data of elderly people with dementia. It is not suitable for recommending care plans for elderly people with dementia. The feature representation of the method does not utilize the information of the text itself. In addition, the bipartite graph does not fully utilize the rich relationship between the elderly, features and care plans.
[0006] In order to further improve the accuracy and personalization of care plans for elderly people with dementia, this application proposes a method for recommending care suggestions based on knowledge graphs and graph attention mechanisms. This method not only takes user features and care suggestions as vertices and uses care rules to build a graph, but also introduces a graph attention neural network to optimize the vector representation of nodes, thereby improving the recommendation effect. Compared with traditional methods, this application aims to provide more practical and targeted personalized care suggestions based on specific care problems, so as to meet the diverse needs of disabled and demented elderly people and promote the intelligent development of the care industry. Summary of the invention
[0007] To address the shortcomings of the prior art, the present invention provides a method and model for recommending care suggestions based on knowledge graphs and graph attention mechanisms. By integrating independently trained Word2Vec, BERT sentence representation, graph attention mechanisms and dual objective functions, the present invention effectively improves the personalization and accuracy of care plan recommendations for elderly people with dementia, providing strong support for the development of the intelligent care industry.
[0008] To achieve the above objectives, the technical solutions adopted by the present invention include:
[0009] A method for recommending care suggestions based on a knowledge graph and a graph attention mechanism, characterized by comprising:
[0010] Extract and preprocess the original case data, obtain the preprocessed data and build the corresponding index;
[0011] Training the original case data with a first algorithm to obtain a first model, and using the first model to initialize a second model to obtain a vector representation of the preprocessed data;
[0012] Obtaining a first user feature vector based on the vector representation of the preprocessed data and the corresponding index;
[0013] Constructing a knowledge graph with the first user feature vector as the center to generate a node relationship matrix;
[0014] The weight ratio between the vector representations of the preprocessed data is obtained by using the graph attention mechanism and the node relationship matrix to determine the second user feature vector;
[0015] The cosine similarity and multi-classification cross entropy are used to construct the relevant loss function of the second user feature vector, and the optimal recommendation model is obtained through the optimization algorithm.
[0016] Exemplarily, the extracting and preprocessing the original case data, obtaining the preprocessed data and constructing the corresponding index includes: extracting basic user characteristics, care problems, care suggestions, and care rules from the original case data, saving them as text data, and creating a basic user characteristic index, a care problem index, and a care suggestion index;
[0017] The category of the care problem is extended to the first user feature, and the category index of the care problem is used to represent the category label of the first user feature, wherein the first user feature includes the user basic feature and the care problem, and the care rule includes the first user feature and the care suggestion.
[0018] Exemplarily, the method of training the original case data with a first algorithm to obtain a first model and initializing the second model with the first model to obtain a vector representation of the preprocessed data includes: training the original case data with a Word2Vec algorithm to obtain a Word2Vec dictionary, and initializing the care questions and the care suggestions based on the Word2Vec dictionary, inputting the processed word vectors into a BERT structure to obtain sentence vectors of care suggestions and care questions, using a user basic feature index to query a user basic feature vector dictionary to obtain a user basic feature vector, and obtaining a first user feature vector by summing the user basic feature vector and the care question sentence vector.
[0019] Exemplarily, the weight ratio between the vector representations of the preprocessed data is obtained by using the graph attention mechanism and the node relationship matrix to calculate and then determine the second user feature vector, including: according to the node relationship matrix, the first user feature node and the care suggestion node are subjected to corresponding linear transformation to obtain the query vector, key vector and value vector of the attention mechanism, and the first user feature node (query vector) and the care suggestion node (key vector) are subjected to the self-attention mechanism to obtain the weight coefficient, and the specific formula involved is as follows:
[0020] e ij =a(q i ,k j )
[0021]
[0022] Among them, a is the shared attention mechanism, which is used to calculate the attention coefficient, q i is the query vector of the first user feature node i, k j is the key vector of the care suggestion node j, e ij The calculated attention coefficient, α ij for e ij The normalized result, N i is the first-order neighbor node of i, that is, the column whose i-th row in the node relationship matrix is 1;
[0023] The second user feature vector is obtained by performing weighted sum calculation on the care suggestion node according to the relationship matrix, the attention coefficient and the value vector. The specific formula is as follows:
[0024]
[0025] Among them, σ is the nonlinear activation function ReLU, α ij To calculate the attention coefficient, v j is the value vector of the care suggestion node j, N i is the first-order neighbor node of i, that is, the column whose i-th row of the node relationship matrix is 1.
[0026] Exemplarily, the use of cosine similarity and multi-classification cross entropy to construct a related loss function for the second user feature vector includes: using cosine similarity to calculate the similarity between the first user feature vector and the second user feature vector to obtain loss function one; using multi-classification cross entropy to evaluate the difference between the model output and the true label of the first user feature vector to obtain loss function two; the loss function is the sum of the loss function one and the loss function two.
[0027] Exemplarily, obtaining the optimal recommendation model through the optimization algorithm includes: optimizing the recommendation model by constructing a training set, a test set and a validation set, wherein the training set is used for actually training the recommendation model, the validation set is used for tuning network parameters and selecting the best model, and the test set is used for evaluating the performance of the recommendation model.
[0028] Exemplarily, the method also includes evaluating the effectiveness of the recommendation model, including: using the care suggestion recommendation score fed back by the user, obtaining the correlation between the first user feature vector and the care suggestion vector, reordering the care suggestions output by the optimal recommendation model, calculating the first NDCG score, and comparing the first score with the second NDCG score of the care suggestions without using the optimal recommendation model, and evaluating the final optimization result.
[0029] The present invention also provides a model for recommending care suggestions applicable to any of the above methods 1-7, characterized in that it includes: an initialization module, a query input module, a vector fitting and prediction module, and a training optimization module; wherein,
[0030] The initialization module is used to construct a vector representation;
[0031] The query input module is used to extract the first feature vector of the user;
[0032] The vector fitting and prediction module is used to aggregate and weight to obtain the second eigenvector and construct a loss function;
[0033] The training optimization module is used to optimize the parameters related to the loss function;
[0034] Exemplarily, the model further includes:
[0035] A care suggestion output module is used to generate a personalized care suggestion list;
[0036] Feedback evaluation module is used to evaluate the recommendation results of the optimal parameters.
[0037] The present invention also provides an electronic device, characterized in that it includes a processor and a memory;
[0038] The memory is used to store computer programs;
[0039] The processor is configured to execute the method according to any one of claims 1 to 7 by calling a stored computer program.
[0040] The present invention also relates to a computer program product, comprising a computer program and / or instructions, characterized in that the computer program and / or instructions are executed by a processor to implement the steps of any of the methods described in 1-7 above.
[0041] The beneficial effects of the present invention are:
[0042] The independently trained Word2Vec model provides a more targeted representation for initializing word vectors. Compared with random initialization, it not only significantly improves the convergence speed of the model, but also enhances the final recommendation effect, allowing the model to better capture the subtle features in the care data.
[0043] The BERT model fully considers the context and order information of the sentence to ensure a deep understanding of the sentence, so that the model can more accurately grasp the semantic relationship when dealing with complex care problems, thereby generating more reasonable care recommendations.
[0044] By introducing the graph attention neural network, the system can more effectively learn the intrinsic relationships in the knowledge graph. This mechanism optimizes the learning process of word vectors by focusing on the importance of different nodes, thereby better reflecting the relationship between the first user features and care recommendations.
[0045] The design of two objective functions improves the learning efficiency of the model and enhances its generalization ability and robustness. This combination of loss functions enables the model to not only adapt to diverse input features, but also maintain stable performance when facing new situations. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 This is a flowchart of a method for recommending care suggestions based on a knowledge graph and a graph attention mechanism according to the present invention.
[0047] Figure 2 This is a structural diagram of the care suggestion model based on the knowledge graph and graph attention mechanism of the present invention.
[0048] Figure 3This is a schematic diagram of the connection logic flow of the technical means adopted by the present invention. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0050] The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0051] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0052] The first aspect of the present application provides a method for recommending care suggestions based on a knowledge graph and a graph attention mechanism, such as Figure 1 and 3 As shown, it is characterized by comprising:
[0053] Extract and preprocess the original case data, obtain the preprocessed data and build the corresponding index;
[0054] Training the original case data with a first algorithm to obtain a first model, and using the first model to initialize a second model to obtain a vector representation of the preprocessed data;
[0055] Obtaining a first user feature vector based on the vector representation of the preprocessed data and the corresponding index;
[0056] Constructing a knowledge graph with the first user feature vector as the center to generate a node relationship matrix;
[0057] The weight ratio between the vector representations of the preprocessed data is obtained by using the graph attention mechanism and the node relationship matrix to determine the second user feature vector;
[0058] The cosine similarity and multi-classification cross entropy are used to construct the relevant loss function of the second user feature vector, and the optimal recommendation model is obtained through the optimization algorithm.
[0059] S1: Sort out basic user characteristics, care problems, care suggestions, and care rules from the original case data.
[0060] S101 original case data examples:
[0061] Table 1 Original case data
[0062]
[0063]
[0064] S102: Extracting basic user characteristics from the original case data. The first basic user characteristics include three categories: patient gender, disease severity, and walking ability. The values of each characteristic are as follows:
[0065] Table 2 Basic feature extraction data of the first user
[0066]
[0067] S103: constructing a user basic feature index according to S102, and counting the number of basic features of the first user.
[0068] Table 3 First user basic feature index table
[0069]
[0070]
[0071] S104: Extract care problems and categories from the original case data. The problem categories include eating, dressing and undressing, excretion, bathing and washing, communication, etc. The specific care problems are as follows:
[0072] Table 4 Extracted user care questions and category data
[0073] Care issues Question Category Not choosing food Eating Not dressing in order Dressing and undressing Forgetting to wash or brush your teeth Bath and Wash ……
[0074] S105: Construct a care problem index according to S104.
[0075] Table 5 Index of care problems
[0076] index Text content 0 Not choosing food 1 Not dressing in order 2 Forgetting to wash or brush your teeth ……
[0077] Table 6 Index of care problem categories
[0078]
[0079]
[0080] S106: Extract care recommendations from raw case data.
[0081] Table 7 Extracted case data of care recommendations
[0082]
[0083] S107: Construct a care recommendation index according to S106.
[0084] Table 8 Index of care recommendations
[0085]
[0086] S108: Extracting care rules from the original case data, including the first user characteristics (basic user characteristics + care problems) and care suggestions.
[0087] Table 9 Extraction data of care rules
[0088]
[0089]
[0090] S109: According to the care problem, the category of the care problem is expanded to the first user feature, and the category label of the first user feature is represented by a category index.
[0091] Table 10 Category labels of the first user feature
[0092]
[0093] S2: Use the original case data as corpus to pre-train a word2vec word vector;
[0094] S201: The original case data is used as corpus without word segmentation as input of the word2vec algorithm.
[0095] S202: Set the Word2vec algorithm to skip-gram mode, the vector dimension of the output word to 10, the training window size to 5, the number of training times to 5, and start training.
[0096] S203: S202 training is completed, and two variables, dictionary vocab and word vector w2v_emb, are output.
[0097] S3: Use the word2vec dictionary to initialize care problems / care suggestions, and then input them into the BERT structure to generate sentence vector representations of care problems and care suggestions;
[0098] S301: Load the word2vec dictionary vocab and word vector w2v_emb, add three special words PAD, UNK and CLS to vocab, PAD represents the word vector used to fill in the sentence length when it is less than the maximum length, initialized with all zeros, UNK represents an unregistered word, CLS represents a sentence vector, and UNK and CLS are randomly initialized.
[0099] S302: According to the word2vec dictionary vocab, the care problem is converted to convert each sentence into a word id list (i.e., the index of the word in vocab). The maximum length of the sentence is set to 20. If the length exceeds the limit, it is truncated. If the length is not enough, the corresponding id of PAD is used to fill it.
[0100] S303: Count the number of question categories and generate onehot representations for the question categories.
[0101] S304: According to the word2vec dictionary vocab, the care problems in the care advice document are converted, and each sentence is converted into a word id list. The maximum length of the sentence is set to 20. If the length exceeds the limit, the sentence is truncated. If the length is insufficient, the corresponding id is filled with PAD.
[0102] S305: Create a variable to save the correspondence between the care suggestion number and the location, and count the number of care suggestions.
[0103] S306: Build a BERT structure, input a sentence id list, add a special word CLS at the head, read the vector w2v_emb according to the id, as the initial vector, add the position vector, that is, the position of each word in the sentence, the position vector is randomly initialized, and a multi-head word attention structure is established. The word vector and the position vector of the sentence are added and input into the multi-head attention structure. The output passes through two layers of fully connected networks, dropout and layer_norm, takes out the first character vector and passes through another layer of fully connected networks, then uses tanh as the activation function, and finally outputs the sentence vector.
[0104] S307: Input the word id list of the care problem in S302 into the BERT structure of S304, and output the sentence vector representation of the care problem;
[0105] S308: Input the ID list of the care suggestions in S303 into the BERT structure of S304, and output the sentence vector representation of the care suggestions.
[0106] S4: Generate a first user feature vector;
[0107] S401: construct a user basic feature vector dictionary based on the user basic feature index in S103, set the dimension to [number of user basic features, 10], and perform random initialization.
[0108] S402: According to the user basic features in the care rule of S108 and the user basic feature index of S103, obtain the index of the user basic features, query the user basic feature vector dictionary of S401 according to the index, and add the query results to obtain the first user basic feature vector that meets the care rule.
[0109] S403: Obtain a care problem index according to the care problem in the care rule in S108 and the care problem index in S105, and query the care problem vector in S307 according to the index.
[0110] S404: Add the user basic feature vector of S402 and the care problem vector of S403 to obtain a first user feature vector that meets the final care rule of S108.
[0111] S5: Build a knowledge graph with the first user feature as the center and generate a node relationship matrix;
[0112] S501: The first user feature vector node of S404 is represented by u, where u={u1,...,u i ,...,u N},u i ∈R F ,N represents the number of the first user features, and F represents the number of features, which is set to 10 here.
[0113] S502: The care suggestion node in S308 is represented by s, s={s1,s2,...,s j ,...,s M},s j
[0114] ∈R F ,M represents the number of care suggestions, and F represents the number of features, which is set to 10 here.
[0115] S503: Construct a knowledge graph with the first user feature as the central node, the care suggestions as the outer nodes, and the care rules as the edges. The node relationship matrix R is:
[0116]
[0117] Among them, the rows represent N first user feature nodes, the columns represent M care suggestion nodes, and r ij The value is 0 or 1, r ij =1 indicates the first user feature u i Can provide care recommendations j .
[0118] S6: Construct graph attention module;
[0119] S601: Perform a linear transformation on the first user feature node of S501, as shown in the following formula:
[0120] q i =u i W q
[0121] Among them, W q is the linear transformation matrix, W q ∈R F×F ,q i Think of it as the query vector of the attention mechanism;
[0122] S602: Perform a linear transformation on the care suggestion node of S502, as shown in the following formula:
[0123] k j =s j W k
[0124] Among them, W k is the linear transformation matrix, W k ∈R F×F , k j is the key vector of the attention mechanism;
[0125] S603: Perform another linear transformation on the care suggestion node of S502, as shown in the following formula:
[0126] v j =s j W v
[0127] Among them, W v is the linear transformation matrix, W v ∈R F×F , v j is the value vector of the attention mechanism;
[0128] S604: According to the relationship matrix R, a self-attention mechanism is performed on the first user feature node and the care suggestion node, and a weight coefficient is obtained, as shown in the following formula:
[0129] e ij =a(q i ,k j )
[0130]
[0131] Among them, a is the shared attention mechanism used to calculate the attention coefficient, e ij The calculated attention coefficient, α ij is the normalization coefficient of iis the first-order neighbor node of i, that is, the i-th row of the relationship matrix in S503 has a column of 1.
[0132] S605: According to the relationship matrix, the attention coefficient and the S604 value vector, a weighted sum is performed on the care suggestion nodes to obtain a new household feature vector. The specific formula is as follows:
[0133]
[0134] Among them, σ is the nonlinear activation function ReLU, α ij is the attention coefficient calculated in S604, v j is the value vector of node j, N i is the first-order neighbor node of i, that is, the column whose i-th row of the relationship matrix in S503 is 1.
[0135] S7: Fit vector and construct loss function;
[0136] S701: Task 1: The second user feature vector u' obtained through attention mechanism learning i As close as possible to the first user feature vector u i resemblance.
[0137] S702: Construct loss function 1 according to task 1, using the second user feature vector u' in S605 i and the first user feature vector u in S404 i The consine distance is the loss function, and the specific form is:
[0138]
[0139] S703: Task 2: multi-classify the second user feature vector so that the predicted classification result is as consistent as possible with the actual category label. i After full connection, the dimension is converted to (1, number of label categories), and multi-classification is performed through softmax to obtain the probability of each category. The specific form of the probability that the i-th second user feature is the k-th category is:
[0140]
[0141] S704: The goal of Task 2 is to make the predicted result and the actual result as consistent as possible. Based on this, loss function 2 is constructed, and the category probability of the second user feature obtained in S703 and the cross entropy of the actual label are used as the loss function. The specific expression is:
[0142]
[0143] Among them, y i,kis the actual label of the first i samples belonging to the kth category. When sample i belongs to category k, y i,k =1; otherwise y i,k =0. ik is the probability that the model predicts the i-th sample as class k, p ik The value range is [0,1], N is the number of samples, and K is the number of categories. i,k =p ik Minimal loss.
[0144] S705: The loss function of S701 and the loss function of S702 are summed up as the final loss function.
[0145] S706 sets the optimizer to AdamOptimizer, calculates the loss, and updates the network model parameters by back propagation based on gradient descent.
[0146] S8: Construct training set, validation set and test set.
[0147] S801: Divide the first user feature label in the graph into a training set, a validation set and a test set in a ratio of 8:1:1, and use a random selection method for node division.
[0148] S9: Optimizing Hyperparameter Training
[0149] S901: Set parameters, batch learning batch_size = 1, learning rounds epochs = 10, learning rate is initially 0.001, and gradually decreases with the increase of iteration number, random inactivation parameter = 0.9, etc.
[0150] S902: Perform training according to S8, and use back-propagation gradient descent to optimize the parameters in the network. The validation set is used to save the optimal model during the training process.
[0151] S903: Use the test set to test the effect.
[0152] S1001: Collect feedback data of user's historical recommendation results, the feedback data includes scores 4, 3, 2, 1, indicating satisfaction with care recommendations.
[0153] In S1002: the optimal recommendation model of the present invention is used to obtain the first user feature vector and the care suggestion vector to calculate the correlation, reorder the recommendation results, calculate the NDCG score, and in addition, calculate the original NDCG score without the present invention, and compare the effects before and after optimization.
[0154]
[0155]
[0156] Among them, k is the number of recommended items, rel i The relevance score of item i is calculated based on the score of user feedback data. Specific embodiment 2:
[0158] This application also provides a model for recommending care suggestions based on knowledge graph and graph attention mechanism, such as Figure 2 As shown, it is characterized by comprising: an initialization module, a query input module, a vector fitting and prediction module, and a training optimization module;
[0159] The initialization module is used to construct a vector representation;
[0160] The query input module is used to extract the first feature vector of the user;
[0161] The vector fitting and prediction module is used to obtain the second eigenvector by aggregation and weighting, and to construct a loss function;
[0162] The training optimization module is used to optimize the parameters related to the loss function;
[0163] The model also includes:
[0164] A care suggestion output module is used to generate a personalized care suggestion list;
[0165] Feedback evaluation module is used to evaluate the recommendation results of the optimal parameters.
[0166] According to the steps in the above method, the specific case display can be:
[0167] The basic characteristics of the user are input into the query input module: male, normal walking, moderate dementia; care problem: refusal to wear clothes. Actual category label: 1 (dressing and undressing).
[0168] By querying the dictionary of user basic feature vectors, the vector representation of the user's basic features is obtained. The vector representation of the care problem is obtained through word2vec+BERT, and the user's basic feature vector and the care problem vector are added to obtain the first user feature vector. Then, in the vector fitting and prediction module, according to the node relationship in the knowledge graph, the information of the first user feature node and the neighboring nodes is aggregated to obtain the second user feature vector. Finally, the prediction results of the model in each category are obtained through full connection and softmax multi-classification.
[0169] In the above case, the actual label is 1, so the value of the 1 label category is 1, and the other labels are 0. If the predicted value on the 0 label is 0.01, the predicted value on the 1 label is 0.86, and the predicted value on the 2 label is 0.11... According to the above loss function loss2, the loss of the model can be calculated, that is, the gap between the predicted result and the actual result.
[0170] S705: The loss function of S701 and the loss function of S702 are summed up as the final loss function.
[0171] In the training optimization module, that is, S706 in the method step, the optimizer is set to AdamOptimizer, the loss is calculated, and the network model parameters are updated by back propagation according to gradient descent.
[0172] At the same time, S8: construct training set, validation set and test set.
[0173] S801: Divide the first user feature label in the graph into a training set, a validation set and a test set in a ratio of 8:1:1, respectively, and use a random selection method for node division.
[0174] S9: Optimize hyperparameter training;
[0175] S901: Set parameters, batch learning batch_size = 1, learning rounds epochs = 10, learning rate is initially 0.001, and gradually decreases with the increase of iteration number, random inactivation parameter = 0.9, etc.
[0176] S902: Perform training according to S8, and use back-propagation gradient descent to optimize the parameters in the network. The validation set is used to save the optimal model during the training process.
[0177] S903: Use the test set to test the effect.
[0178] Outputting a recommendation list of care suggestions by a care suggestion output module;
[0179] Finally, after the model optimization is completed, step S10 is executed in the feedback evaluation module: the effect is evaluated on the data set of actual user feedback;
[0180] S1001: Collect feedback data of user's historical recommendation results, the feedback data includes scores 4, 3, 2, 1, indicating satisfaction with care recommendations.
[0181] In S1002: the optimal recommendation model of the present invention is used to obtain the first user feature vector and the care suggestion vector to calculate the correlation, reorder the recommendation results, calculate the NDCG score, and in addition, calculate the original NDCG score without the present invention, and compare the effects before and after optimization.
[0182]
[0183]
[0184] Among them, k is the number of recommended items, rel i The relevance score of item i is calculated based on the score of user feedback data.
[0185] By using this system, the above-mentioned operation processing method can be executed and the corresponding technical effects can be achieved. Specific embodiment three:
[0187] A user case is constructed, and the first user feature is: gender: female, disease course: mild, walking ability: can walk normally, care problem: forget to eat, want to eat again after eating. The results of the care suggestions recommended before and after using the method of the present invention are shown below.
[0188] Output:
[0189] The first user feature is:
[0190] Female, mild, can walk normally, forgets to eat, still wants to eat after eating
[0191] Recommended care tips:
[0192] --------------After using the graph attention mechanism-----------
[0193] Provide a small amount of snacks such as fruits or biscuits, or divide the food into several small portions and give them to the elderly one by one to control their food intake; or give appropriate low-calorie, high-fiber vegetables such as celery, bamboo shoots, green vegetables, Chinese cabbage, winter melon, etc.;
[0194] Put away food and avoid leaving it in plain sight;
[0195] Make a meal record sheet and ask the elderly to tick a box after each meal.
[0196] Take the elderly out or do something interesting for them, such as watching TV, listening to the radio, taking a walk, etc. to divert their attention;
[0197] You can put the newly used dishes in the washing basin to remind the elderly that they have already eaten. Communicate more with the elderly and find out why they keep asking for food.
[0198] Don't blame, persuade, or show annoyance.
[0199] NDCG: 0.99
[0200] --------------Before using graph attention mechanism------------
[0201] Don’t blame, persuade, or show annoyance;
[0202] Communicate more with the elderly and find out why they keep asking for food;
[0203] Provide a small amount of snacks such as fruits or biscuits, or divide the food into several small portions and give them to the elderly one by one to control their food intake; or give appropriate low-calorie, high-fiber vegetables such as celery, bamboo shoots, green vegetables, Chinese cabbage, winter melon, etc.;
[0204] Put away food and avoid leaving it in plain sight;
[0205] Take the elderly out or do something interesting for them, such as watching TV, listening to the radio, taking a walk, etc. to divert their attention;
[0206] You can put the recently used dishes in the washing basin to remind the elderly that they have already eaten;
[0207] Make a meal record sheet and ask the elderly to tick a box after each meal.
[0208] NDCG: 0.98
[0209] It can be seen that after using the method of the present invention, practical suggestions are ranked higher, and general or general suggestions are ranked lower. The NDCG score is calculated based on the user's scoring results, and the score is higher after using the method of the present invention.
[0210] Specific embodiment four: An embodiment of the present invention also provides an electronic device for executing the above method. As an implementation device of the method, the electronic device at least has a processor and a memory, and in particular, the memory stores data and related computer programs required for executing the method, such as storing set calculation programs, etc., and the processor calls the data and programs in the memory to execute all the steps of the implementation method and obtains the corresponding technical effects.
[0211] Preferably, the electronic device may include a bus architecture, the bus may include any number of interconnected buses and bridges, and the bus will include various circuits linked together by one or more processors and memories. The bus may also link together various other circuits such as peripherals, voltage regulators, and power management circuits, which are all well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the receiver and transmitter. The receiver and transmitter may be the same component, i.e., a transceiver, providing a unit for communicating with various other systems over a transmission medium. The processor is responsible for managing the bus and general processing, while the memory may be used to store data used by the processor when performing operations.
[0212] In addition, the electronic device may further include components such as a communication module, an input unit, an audio processor, a display, and a power supply. The processor (or controller, operation control) used may include a microprocessor or other processor device and / or a logic device, which receives input and controls the operation of various components of the electronic device; the memory may be one or more of a cache, a flash memory, a hard drive, a removable medium, a volatile memory, a non-volatile memory, or other suitable devices, which may store the above-mentioned related data information, and may also store a program for executing related information, and the processor may execute the program stored in the memory to realize information storage or processing, etc.; the input unit is used to provide input to the processor, for example, it may be a key or a touch input device; the power supply is used to provide power to the electronic device; the display is used to display display objects such as images and text, for example, it may be an LCD display. The communication module is a transmitter / receiver that sends and receives signals via an antenna. The communication module (transmitter / receiver) is coupled to the processor to provide input signals and receive output signals, which may be the same as the case of a conventional mobile communication terminal. Based on different communication technologies, multiple communication modules may be provided in the same electronic device, such as a cellular network module, a Bluetooth module and / or a wireless local area network module, etc. The communication module (transmitter / receiver) is also coupled to a speaker and a microphone via an audio processor to provide an audio output via the speaker and receive an audio input from the microphone, thereby realizing a common telecommunication function. The audio processor may include any suitable buffer, decoder, amplifier, etc. In addition, the audio processor is also coupled to a central processor, so that recording can be performed on the machine through the microphone, and the sound stored on the machine can be played through the speaker.
[0213] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, models, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0214] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A system that specifies the functions of a box or multiple boxes.
[0215] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction system, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0216] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps of the functions specified in a box or multiple boxes. Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they know the basic creative concept. Therefore, the attached claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0217] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for recommending care suggestions based on knowledge graph and graph attention mechanism, characterized in that: include: Extract and preprocess the original case data, obtain the preprocessed data and build the corresponding index; Training the original case data with a first algorithm to obtain a first model, and using the first model to initialize a second model to obtain a vector representation of the preprocessed data; Obtaining a first user feature vector based on the vector representation of the preprocessed data and the corresponding index; Constructing a knowledge graph with the first user feature vector as the center to generate a node relationship matrix; The weight ratio between the vector representations of the preprocessed data is obtained by using the graph attention mechanism and the node relationship matrix to determine the second user feature vector; The cosine similarity and multi-classification cross entropy are used to construct the relevant loss function of the second user feature vector, and the optimal recommendation model is obtained through the optimization algorithm.
2. The method according to claim 1, characterized in that The extracting and preprocessing the original case data, obtaining the preprocessed data and constructing the corresponding index comprises: extracting the user's basic characteristics, care problems, care suggestions, and care rules from the original case data, saving them as text data, and creating a user's basic characteristics index, a care problem index, and a care suggestion index; The category of the care problem is extended to the first user feature, and the category index of the care problem is used to represent the category label of the first user feature, wherein the first user feature includes the user basic feature and the care problem, and the care rule includes the first user feature and the care suggestion.
3. The method according to claim 2, characterized in that The method of obtaining a first model by training the original case data with a first algorithm and obtaining a vector representation of the preprocessed data by initializing the second model with the first model includes: training the original case data with a Word2Vec algorithm to obtain a Word2Vec dictionary, initializing the care questions and the care suggestions based on the Word2Vec dictionary, inputting the processed word vectors into a BERT structure to obtain sentence vectors of the care suggestions and the care questions, querying the user basic feature vector dictionary with a user basic feature index to obtain the user basic feature vector, and obtaining a first user feature vector by summing the user basic feature vector and the care question sentence vector.
4. The method according to claim 3, characterized in that The method of using the graph attention mechanism and the node relationship matrix to calculate the weight ratio between the vector representations of the preprocessed data and then determining the second user feature vector includes: according to the node relationship matrix, the first user feature node and the care suggestion node are subjected to corresponding linear transformation to obtain the query vector, key vector and value vector of the attention mechanism, and the first user feature node (query vector) and the care suggestion node (key vector) are subjected to the self-attention mechanism to obtain the weight coefficient, and the specific formula involved is as follows: e ij =a(q i ,k j ) Among them, a is the shared attention mechanism, which is used to calculate the attention coefficient, q i is the query vector of the first user feature node i, k j is the key vector of the care suggestion node j, e ij The calculated attention coefficient, α ij for e ij The normalized result, N i is the first-order neighbor node of i, that is, the column whose i-th row in the node relationship matrix is 1; The second user feature vector is obtained by performing weighted sum calculation on the care suggestion node according to the relationship matrix, the attention coefficient and the value vector. The specific formula is as follows: Among them, σ is the nonlinear activation function ReLU, α ij To calculate the attention coefficient, v j is the value vector of the care suggestion node j, N i is the first-order neighbor node of i, that is, the column whose i-th row of the node relationship matrix is 1.
5. The method according to claim 4, characterized in that The method of using cosine similarity and multi-classification cross entropy to construct a related loss function for the second user feature vector includes: using cosine similarity to calculate the similarity between the first user feature vector and the second user feature vector to obtain loss function one; using multi-classification cross entropy to evaluate the difference between the model output and the true label of the first user feature vector to obtain loss function two; the loss function is the sum of the loss function one and the loss function two.
6. The method according to claim 5, characterized in that The method of obtaining the optimal recommendation model through the optimization algorithm includes: optimizing the recommendation model by constructing a training set, a test set and a validation set, wherein the training set is used for actually training the recommendation model, the validation set is used for tuning network parameters and selecting the best model, and the test set is used for evaluating the performance of the recommendation model.
7. The method according to claim 6, characterized in that The method also includes evaluating the effectiveness of the recommendation model, including: using the care suggestion recommendation score fed back by the user, obtaining the correlation between the first user feature vector and the care suggestion vector, reordering the care suggestions output by the optimal recommendation model, calculating the first NDCG score, and comparing the first score with the second NDCG score of the care suggestions without using the optimal recommendation model, and evaluating the final optimization result.
8. A model for recommending care advice applicable to any of the methods 1-7 above, characterized in that: include: Initialization module, query input module, vector fitting and prediction module, training optimization module; The initialization module is used to construct a vector representation; The query input module is used to extract the first feature vector of the user; The vector fitting and prediction module is used to obtain the second eigenvector by aggregation and weighting, and to construct a loss function; The training optimization module is used to optimize the parameters related to the loss function.
9. An electronic device, characterized in that: including a processor and a memory; The memory is used to store computer programs; The processor is configured to execute the method according to any one of claims 1 to 7 by calling a stored computer program.
10. A computer program product comprising a computer program and / or instructions, characterized in that: When the computer program and / or the instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Establishing a system and methodology based on elderly care guidelines and a knowledge base of disability and dementia.
CN110648737B