Big language model-based diet recommendation method, system and equipment and medium

Through a diet recommendation system based on a large language model, user data is integrated to generate personalized diet plans, which solves the problem that existing systems are unable to deeply understand nutritional knowledge and comprehensively consider physiological signals, and realizes accurate and explainable diet recommendations.

CN120673987APending Publication Date: 2025-09-19北京豆果信息技术有限公司 +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510651720.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-20
Publication Date
2025-09-19

AI Technical Summary

Technical Problem

Existing diet recommendation systems lack a deep understanding of the massive health and nutrition knowledge base, are unable to comprehensively consider individual physiological signals and environmental factors, and the personalized recommendations are insufficiently explainable.

Method used

Using a method based on a large language model, we integrate basic user data and physiological data, generate personalized diet recommendations through a pre-trained multi-head attention model, and provide detailed reasons and precautions for recommendations based on the nutrition database and user profile.

Benefits of technology

It has achieved accurate and personalized dietary recommendations, improved the professionalism and scientific nature of the recommendation plans, enhanced users' understanding and trust in the recommendation results, and improved user acceptance and compliance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120673987A_ABST
    Figure CN120673987A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of language processing, and particularly discloses a diet recommendation method, system and device based on a large language model and a medium. Comprising the following steps: acquiring user basic data and user physiological data; obtaining a user health target, and inputting the user health target, the user basic data and the user physiological data into a pre-trained large language model to obtain a user portrait; and inputting a preset nutrition database and the user portrait into a pre-trained multi-head attention model to generate a diet recommendation scheme. By fusing multi-source user data and combining semantic comprehension and knowledge mining ability of a large language model and feature interaction capture ability of a multi-head attention model, accurate and personalized diet recommendation conforming to health constraints is realized, and scientificity, practicability and user acceptability of a recommendation scheme are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of language processing technology, and in particular to a diet recommendation method, system, device and medium based on a large language model. Background Art

[0002] As people pay more and more attention to healthy lifestyles, a variety of healthy diet recommendation systems based on nutritional knowledge and personal physical characteristics have emerged on the market. For example:

[0003] (1) Dietary recommendations based on rules or expert systems: Dietary and nutritional rules are manually formulated by nutrition experts and then matched based on the physiological data provided by the user (such as age, gender, height, weight or BMI). In practical applications, such systems often have problems such as insufficient personalization and poor scalability.

[0004] (2) Personalized recommendations based on traditional machine learning: This type of method usually combines the user's diet records, exercise data, and weight changes on the health management platform, and uses collaborative filtering or classification regression models to make recommendations. However, due to the vast and complex knowledge in the field of nutrition, traditional machine learning models often face challenges such as high dimensionality and sparse data when processing large-scale health knowledge bases. At the same time, they are unable to flexibly capture the health needs implicit in users' natural language descriptions.

[0005] (3) Literature and question-answering systems based on small natural language processing models: Traditional NLP models (such as LSTM and RNN) can provide basic semantic analysis for nutrition questions and answers, but they have limited capabilities in deep semantic understanding of massive health consultation texts and personalized diet scenarios, and it is difficult to deeply understand complex contextual information.

[0006] None of the above methods can automatically obtain personalized health needs in natural language, and the following major problems exist:

[0007] Lack of in-depth understanding of the massive health and nutrition knowledge base: Existing systems typically rely on limited nutrition rules or small-scale text data, making it difficult to flexibly answer complex dietary health questions.

[0008] Lack of comprehensive consideration of personal physiological signals and environmental factors: Traditional recommendation systems often only focus on age, gender or body mass index (BMI).

[0009] Insufficient explainability of personalized recommendations: Users lack a deep understanding of why the recommendations are suitable for them and the underlying principles, which hinders continued use and trust. Summary of the Invention

[0010] In view of this, embodiments of the present invention provide a diet recommendation method, system, device and medium based on a large language model to solve the technical problem that existing diet recommendation methods lack comprehensive consideration of user physiological characteristics, resulting in inaccurate recommendation results.

[0011] To achieve the above objectives, in a first aspect, a diet recommendation method based on a large language model is provided, comprising the following steps:

[0012] Obtain user basic data and user physiological data;

[0013] Obtaining a user's health goal, and inputting the user's health goal, the user's basic data, and the user's physiological data into a pre-trained large language model to obtain a user profile;

[0014] The preset nutrition database and the user profile are input into the pre-trained multi-head attention model to generate a diet recommendation plan.

[0015] In a second aspect, a diet recommendation system based on a large language model is provided, comprising:

[0016] Data acquisition module, used to obtain user basic data and physiological data;

[0017] A portrait creation module is used to obtain a user's health goals and input the user's health goals, the user's basic data, and the physiological data into a pre-trained large language model to obtain a user portrait;

[0018] A plan generation module is used to input the user portrait into the large language model to generate a diet recommendation plan.

[0019] According to a third aspect, an electronic device is provided, comprising:

[0020] one or more processors;

[0021] a storage device for storing one or more programs,

[0022] When the one or more programs are executed by the one or more processors, the one or more processors implement a diet recommendation method based on a large language model as described in the first aspect.

[0023] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method for recommending a diet based on a large language model as described in the first aspect is implemented.

[0024] The above technical solution has the following beneficial technical effects:

[0025] This invention integrates basic user data, physiological data, and health goals to create a comprehensive user profile, providing multi-dimensional input to the multi-head attention model and enabling precise, personalized dietary recommendations. For example, it combines basic user information such as age, gender, height, and weight with physiological indicators such as real-time blood sugar and heart rate, as well as specific health goals (such as weight loss or muscle gain) to generate a diet plan that meets the user's health needs.

[0026] Leveraging the powerful semantic understanding capabilities of large language models, we can deeply explore nutrition domain knowledge, accurately grasp the semantic information of users' health goals, provide high-quality input to the multi-head attention model, and enhance the professionalism and scientific nature of recommendations. For example, we can understand the specific dietary requirements (low sugar, high protein) in a user's goals and generate reasonable dietary recommendations based on the nutritional knowledge base.

[0027] The multi-head attention model captures the complex interactions between the nutritional database and user profiles, fully considering the correlations between different nutrients, food characteristics, and user characteristics to generate comprehensive and balanced dietary recommendations. For example, for users who need to control blood sugar, it considers the carbohydrate content, glycemic index, and the user's metabolic status to generate a low-glycemic-index and nutritionally balanced diet plan.

[0028] Generate recommendation reasons and precautions through a large language model, explain the basis and benefits of the recommendation plan in natural language, enhance users' understanding and trust in the recommendation results, and improve user acceptance and compliance. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The accompanying drawings are provided for a better understanding of the present invention and are not intended to limit the present invention.

[0030] Figure 1 is a flow chart of a diet recommendation method based on a large language model in an embodiment of the present invention;

[0031] Figure 2 is a flow chart of step S10 in an embodiment of the present invention;

[0032] Figure 3 is a flow chart of step S20 in an embodiment of the present invention;

[0033] Figure 4 is a flow chart of step S22 in an embodiment of the present invention;

[0034] Figure 5 is a flow chart of step S30 in an embodiment of the present invention;

[0035] Figure 6 This is a structural block diagram of a diet recommendation system based on a large language model in an embodiment of the present invention;

[0036] Figure 7 is a structural block diagram of a data acquisition module in an embodiment of the present invention;

[0037] Figure 8 It is a schematic diagram of the structure of a computer system according to an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The following description of exemplary embodiments of the present invention is made in conjunction with the accompanying drawings, in which various details of the embodiments of the present invention are included to facilitate understanding. These details should be considered as merely exemplary. Therefore, it should be appreciated by those skilled in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0039] Example 1

[0040] like Figure 1 As shown, this embodiment provides a diet recommendation method based on a large language model, comprising the following steps:

[0041] S10: Obtaining user basic data and user physiological data;

[0042] S20: Obtaining a user health goal, and inputting the user health goal, the user basic data, and the user physiological data into a pre-trained large language model to obtain a user profile;

[0043] S30: Inputting the preset nutrition database and the user portrait into a pre-trained multi-head attention model to generate a diet recommendation plan.

[0044] Specifically, the user basic data includes the user's name, user's gender, user's age, user's height, user's information, medical history and dietary taboos, and the user can choose to input the user basic data by voice, digital input or text.

[0045] Specifically, the user physiological data includes the user's blood sugar, heart rate, blood pressure, body temperature and sleep quality, etc. The user physiological data is obtained through a wearable device (for example, a smart bracelet or a smart watch, etc.), and the wearable device is used by the user.

[0046] Specifically, if Figure 2 As shown, in the step S10, the following steps are included:

[0047] S11: Obtaining original user physiological data and original user basic data from several data sources;

[0048] S12: using a dynamic protocol adaptation method to identify the original user physiological data and the original user basic data to obtain multi-source physiological data and multi-source basic data;

[0049] S13: Preprocessing the multi-source physiological data and the multi-source basic data to obtain user basic data and user physiological data.

[0050] Specifically, in step S11, the multiple data sources include not only the above-mentioned wearable devices, but also smart measuring instruments such as mobile applications, blood pressure monitors or weight scales. The original user physiological data and the original user basic data are obtained from the smart measuring instruments. The original user physiological data and the original user basic data are multimodal data and may include image data, text data or voice data, etc.

[0051] Specifically, for example, users register in a mobile app / mini program and fill in basic user data (age, gender, height, weight, dietary preferences, allergy information, etc.). A wearable device (such as a smart bracelet) is then bound to obtain real-time metrics such as the user's heart rate, blood sugar changes, and exercise steps. The user's BMI, basal metabolic rate, and other data are calculated based on the data obtained by the wearable device and the user's basic data as part of the user's basic data.

[0052] Specifically, in step S12, the dynamic protocol adaptation method is used to automatically identify the data source type and transmission protocol. In terms of technical implementation, the system introduces a rule-based protocol parser and a machine learning model. The parser identifies the data type by analyzing data metadata (such as header fields or metadata), and the model identifies the data structure (such as distinguishing between JSON and XML formats) through the characteristic patterns of the data samples. First, the data structure type of the original user physiological data and the original user basic data is identified. The structure type includes structured data, semi-structured data and unstructured data. For example, information is extracted from health database reading (structured data), user voice or text input (unstructured data) and third-party applications (semi-structured data), such as small programs that come with weight scales or blood pressure monitors.

[0053] Specifically, in step S13, the preprocessing includes data cleaning and data standardization. The data cleaning includes missing value processing, outlier processing, and duplicate data processing. The missing values ​​are processed by deletion or filling. The deletion method is suitable for situations where the missing values ​​account for a low proportion of the overall data, and the data records containing missing values ​​can be directly deleted. The filling method is suitable for numerical data, and the missing values ​​are filled by the mean, median, or mode. For categorical data, the missing values ​​are filled with the value that appears the most times. For example, for a user's weight data, if there are missing values, the average weight of the user at other measurement times can be used to fill them. When processing outliers, outliers are first identified through statistical methods or machine learning algorithms. The statistical methods use the degree of deviation from the mean as the criterion for outlier judgment, and outliers are corrected by deletion or filling. The machine learning algorithm uses the isolation forest model to construct a recognition model to identify outliers. Duplicate data is identified by searching for duplicate records, and the duplicate data is directly deleted until only one record remains.

[0054] Specifically, the data normalization process is used to normalize data of different scales to the same scale, using Z-value normalization or maximum-minimum normalization. For example, Z-value normalization is used to convert heart rate data into a standard normal distribution with a mean of 0 and a standard deviation of 1. The preprocessing also includes categorical data encoding. For categorical data in multi-source basic data, such as gender, occupation, etc., an encoding method is used to convert them into numerical data. The encoding methods include one-hot encoding and label encoding. For example, for gender data, one-hot encoding can be used to encode "male" and "female" as [1,0] and [0,1] respectively.

[0055] Specifically, if Figure 3 As shown, in the step S20, the following steps are included:

[0056] S21: Obtain the user's health goal, input the user's health goal into a pre-trained large language model, and obtain target data;

[0057] S22: performing feature extraction on the target data, the user basic data, and the user physiological data to obtain a number of user features;

[0058] S23: Creating a plurality of user tags based on the plurality of user characteristics;

[0059] S24: Inputting the plurality of user tags into the pre-trained large language model to obtain a user portrait.

[0060] Specifically, the training process of the large language model includes the following steps:

[0061] S211: Obtain health text data;

[0062] S212: Select a model framework and a word segmenter, and compose a large language model to be trained based on the model framework and the word segmenter;

[0063] S213: Preprocessing the health text data to obtain training data;

[0064] S214: Training the large language model to be trained according to the training data until a cutoff condition is met, thereby obtaining a preliminary training model;

[0065] S215: Obtaining corpus in the field of diet and nutrition, adjusting the preliminary training model according to the corpus in the field of diet and nutrition, and obtaining a pre-trained large language model.

[0066] Specifically, the health text data is collected from internet web pages, Wikipedia, books, GitHub, papers, question-and-answer websites, etc. to ensure data diversity and breadth. The amount of data usually needs to reach TB level to cover various topics in the health field.

[0067] Specifically, the model framework uses a generative pre-trained transformer (GPT), a bidirectional encoder representation model, or other Transformer architectures. The Transformer architecture can capture long-range dependencies in text through a self-attention mechanism. The tokenizer is used to process the health text data, dividing it into small units for easier processing.

[0068] Specifically, in step S213, the health text data is input into a word segmenter and converted into a format that the model framework can understand, such as mapping tokens into digital IDs and adding some special tokens or attention masks to obtain training data. In step S214, the large language model to be trained is first pre-trained based on the training data to obtain a preliminary training model. The pre-training includes masked language modeling and causal language modeling. Masked language modeling learns the semantic information in the training data by randomly masking some input words and training the large language model to be trained to predict these words; while causal language modeling allows the large language model to be trained to predict the next word based on the previous words. The preliminary training model is trained with training data so that the first model learns to predict the next word in a sentence or fill in missing words in a sentence. The training process is a process of continuous iterative optimization, the goal of which is to enable the preliminary training model to predict the correct word or sentence as accurately as possible based on the context. The cutoff condition is a preset condition (training target), and backpropagation is used to optimize the model parameters. To accelerate calculations, methods such as gradient accumulation and mixed precision training can be used. At the same time, record indicators such as training loss, accuracy, learning rate, gradient size, etc. to monitor training progress and tune hyperparameters.

[0069] Specifically, in step S215, the preliminary training model has a certain language comprehension ability. In order to make it perform better in specific fields or tasks, adjustments are required. The adjustments include instruction fine-tuning and domain adaptation. By obtaining corpus in the field of diet and nutrition for adjustment, a pre-trained large language model is obtained. The pre-trained large language model can be deployed to the cloud or edge computing platform and combined with the server-side application programming interface or the main device for real-time inference.

[0070] Specifically, if Figure 4 As shown, in the step S22, the following steps are specifically included:

[0071] S221: Classifying the target data, the user basic data, and the user physiological data according to data types, where the data types include structured data, semi-structured data, and unstructured data;

[0072] S222: extracting features from the target data, the user basic data, and the user physiological data, the classification results of which are structured data, according to statistical features to obtain a plurality of first features;

[0073] S223: extracting features of the target data, the user basic data, and the user physiological data, the classification results of which are semi-structured data, using a script object representation method to obtain a plurality of second features;

[0074] S224: extracting features from the target data, the user basic data, and the user physiological data, which are classified as unstructured data, using a natural language processing method to obtain a plurality of third features;

[0075] The plurality of user characteristics include a first characteristic, a second characteristic, and a third characteristic.

[0076] Specifically, the Scripting Object Representation (SOR) is a method for describing and organizing data structures, and is used to process semi-structured or complex data. It represents data in the form of scripted objects, making it easier to operate, access, and process the data. In this method, each data item is regarded as an object, containing properties and methods, which can flexibly map and represent data from different sources and formats. It is usually used to represent content without a strict table structure (such as JSON, XML, log files, etc.). Through the Scripting Object Representation, data can be extracted, processed, and transformed to adapt to a variety of different data sources and needs. Semi-structured data uses regular expressions, XPath, or API tools to parse field values; unstructured data uses Natural Language Processing (NLP) technology, such as the Transformer-based BERT (Bidirectional Encoder Representations from Transformers) model, to extract text embedding features and combine sentiment analysis tools to refine semantic information. In addition, for unstructured media data such as pictures and videos, the system uses convolutional neural networks (CNN) to extract image features or key frame information in videos to ensure comprehensive coverage of multimodal features.

[0077] Specifically, in step S23, when establishing the plurality of user labels based on the plurality of user features, direct label extraction, cluster analysis, and classification algorithms may be employed. The direct label extraction method directly extracts representative and discriminative information as user labels. For example, based on user characteristics such as age, gender, and health goals, labels such as "young female weight loss user" and "middle-aged male hypertension patient" may be directly generated. The cluster analysis method uses the plurality of user features as input to a clustering algorithm, assigns a similarity value to each user feature, and clusters the plurality of user features based on the similarity values ​​to form a plurality of clusters, each corresponding to a user label. The clustering algorithm may employ a K-means clustering algorithm or a density-based spatial clustering algorithm. For example, users with similar eating habits, exercise habits, and health goals may be clustered into a single category labeled "healthy living advocate." The classification algorithm may employ a decision tree algorithm or a support vector machine algorithm to classify new users based on existing user label data and generate corresponding user labels. For example, a classification model may be trained using labeled user data. When new user data is input, the model can automatically assign appropriate user labels.

[0078] Specifically, in step S24, the user tag is first fused with the knowledge and information in the large language model. The user tag is used as the input condition of the large language model, or the user tag is embedded in the parameters of the large language model, so that the large language model can generate content that is more in line with the user's personalized needs based on the user tag. Secondly, the large language model generates a user portrait based on the user tag. The user portrait not only includes the user's basic information and health goals, but also covers information in multiple dimensions such as the user's dietary preferences, exercise habits, and health status, providing a comprehensive basis for the subsequent generation of personalized healthy diet plans. The user portrait is presented to relevant parties in an intuitive and easy-to-understand manner, such as the user himself, a nutritionist, a health manager, etc. The presentation method adopts structured data tables, visual charts, text descriptions, etc., which are convenient for users and professionals to view and understand.

[0079] Specifically, if Figure 5 As shown, in the step S30, the following steps are specifically included:

[0080] S31: Obtaining user portrait features according to the user portrait;

[0081] S32: extracting features from the nutrition database to obtain nutrition features;

[0082] S33: Inputting the nutritional features and the user profile features into a pre-trained multi-head attention model to obtain the recommendation degree of each nutritional feature;

[0083] S34: Selecting a number of the nutritional characteristics according to the recommendation degree as a dietary recommendation plan for output.

[0084] Specifically, in step S31, user profile features are extracted from the user profile. The user profile features include age, gender, height, weight, weight loss, muscle gain, health maintenance, preferred food types, tastes, exercise frequency, exercise type, blood sugar, blood pressure, and blood lipids. After the user profile features are extracted, they are standardized or normalized to facilitate subsequent calculations. Dimensionality reduction can also be performed on the user profile features to remove redundant information and improve processing efficiency and accuracy.

[0085] Specifically, in step S32, the nutritional database is formed by integrating dietary nutrition literature, guidelines, and research results from multiple authoritative institutions. The nutritional characteristics include food calories, protein content, fat content, carbohydrate content, vitamin and mineral content, etc. When extracting the nutritional characteristics, a feature selection algorithm (e.g., principal component analysis algorithm or correlation analysis algorithm) is used for screening.

[0086] Specifically, in step S33, by inputting the user portrait features and the nutritional features into the pre-trained multi-head attention model, a recommendation degree is generated for each nutritional feature through learning and calculation of multiple attention heads. These scores reflect the degree of matching and correlation between different nutritional features and user portrait features. According to the output of the multi-head attention model, the recommendation degree of each nutritional feature is calculated. The score can be normalized so that it falls within a specific interval (for example, between 0 and 1) to facilitate subsequent recommendation decisions. At the same time, the score can be adjusted and optimized according to actual conditions, such as fine-tuning in combination with user feedback or expert knowledge.

[0087] Specifically, in step S33, the multi-head attention model satisfies constraints, including nutrient composition constraints, cooking method constraints, and dietary taboo constraints. Nutrient composition constraints set intake ranges for various nutrients (e.g., protein, fat, carbohydrates, vitamins, minerals, etc.) based on the user's health goals and physiological condition. For example, users who need to control their weight may need to limit their carbohydrate and fat intake, while athletes or manual laborers may need to increase their protein and energy intake. Cooking method constraints restrict the cooking methods of recommended foods, taking into account the impact of different cooking methods on the nutritional composition of food and the user's health needs. For example, for users with hypertension or heart disease, high-salt, high-fat cooking methods such as frying and pickling should be avoided, and healthy cooking methods such as steaming, boiling, stewing, and roasting should be recommended. Dietary taboo constraints are designed to avoid recommending foods that do not conform to the user's dietary habits or foods to which the user has allergies. For example, for vegetarians, foods containing meat should be avoided. For users with nut allergies, nuts are not recommended.

[0088] The constraints are implemented through three methods: feature engineering, attention mechanism adjustment, or setting a loss function. Feature engineering involves extracting features from the constraints to obtain constraint features, which are then used as inputs to the multi-head attention model and their weights are increased. For example, information such as the nutritional content of a food, the type of cooking method, and whether it complies with the user's dietary restrictions can be included as part of the feature vector, allowing the multi-head attention model to fully consider these constraints during learning. The attention mechanism adjustment sets a special attention mask based on the constraints, assigning a special attention mask to input values ​​that do not meet the constraints. Input values ​​with special attention masks are ignored during processing by the multi-head attention model, resulting in an output that meets the constraints. Setting a loss function incorporates the constraints into the loss function during the training of the multi-head attention model, making it one of the optimization objectives of the multi-head attention model. For example, in addition to the traditional prediction error loss, nutrient constraint losses, cooking method constraint losses, and dietary restriction constraint losses can be added, allowing the model to simultaneously consider prediction accuracy and the degree of constraint satisfaction during learning. By rationally incorporating nutrient constraints, cooking method constraints, and dietary taboo constraints into the multi-head attention model, the personalization, scientificity, and practicality of dietary recommendation plans can be improved, better meeting users' health needs and dietary habits.

[0089] Specifically, in step S34, all nutritional features are sorted according to the degree of recommendation, and nutritional features with a large degree of recommendation are preferentially selected as output features based on the sorting results. Based on the output features, corresponding ingredients and cooking methods are screened from the nutritional database to form a dietary recommendation plan. The generated dietary recommendation plan is presented to the user in a clear and intuitive manner. It can be in the form of a recipe list, nutritional component analysis, diet plan table, etc., which is convenient for users to understand and operate. At the same time, some relevant dietary suggestions and precautions can be provided to help users better implement the recommendation plan and achieve their health goals.

[0090] Specifically, the diet recommendation method based on a large language model further includes step S40, wherein step S40: obtaining feedback data from the user after a preset period of time according to the diet recommendation plan, determining whether the health goal has been achieved based on the feedback data and the user's health goal, and if it is determined that the health goal has not been achieved, adjusting the parameters in the large language model and the multi-head attention model. For certain special situations (such as a sudden increase in the user's blood sugar, allergies, etc.), an emergency plan can be triggered and a diet recommendation plan can be regenerated.

[0091] Example 2

[0092] like Figure 6 As shown, this embodiment provides a diet recommendation system based on a large language model, including:

[0093] Data acquisition module, used to obtain user basic data and physiological data;

[0094] A portrait creation module is used to obtain a user's health goals and input the user's health goals, the user's basic data, and the physiological data into a pre-trained large language model to obtain a user portrait;

[0095] A plan generation module is used to input the user portrait into the large language model to generate a diet recommendation plan.

[0096] Specifically, the user basic data includes the user's name, user's gender, user's age, user's height, user's information, medical history and dietary taboos, and the user can choose to input the user basic data by voice, digital input or text.

[0097] Specifically, the user physiological data includes the user's blood sugar, heart rate, blood pressure, body temperature and sleep quality, etc. The user physiological data is obtained through a wearable device (for example, a smart bracelet or a smart watch, etc.), and the wearable device is used by the user.

[0098] Specifically, if Figure 7 As shown, in the data acquisition module, it includes:

[0099] A raw data acquisition unit, configured to acquire raw user physiological data and raw user basic data from a number of data sources;

[0100] an identification unit, configured to identify the original user physiological data and the original user basic data by adopting a dynamic protocol adaptation method to obtain multi-source physiological data and multi-source basic data;

[0101] The preprocessing unit is used to preprocess the multi-source physiological data and the multi-source basic data to obtain user basic data and user physiological data.

[0102] Specifically, in the original data acquisition unit, the several data sources include not only the above-mentioned wearable devices, but also smart measuring instruments such as mobile applications, blood pressure monitors or weight scales. The original user physiological data and the original user basic data are obtained from the smart measuring instruments. The original user physiological data and the original user basic data are multimodal data and may include image data, text data or voice data, etc.

[0103] Specifically, for example, users register in a mobile app / mini program and fill in basic user data (age, gender, height, weight, dietary preferences, allergy information, etc.). A wearable device (such as a smart bracelet) is then bound to obtain real-time metrics such as the user's heart rate, blood sugar changes, and exercise steps. The user's BMI, basal metabolic rate, and other data are calculated based on the data obtained by the wearable device and the user's basic data as part of the user's basic data.

[0104] Specifically, in the identification unit, a dynamic protocol adaptation method is used to automatically identify the data source type and transmission protocol. The system introduces a rule-based protocol parser and a machine learning model. The parser identifies the data type by analyzing data metadata (such as header fields or metadata), and the model identifies the data structure through the characteristic pattern of the data sample (such as distinguishing between JSON and XML formats). First, identify the data structure type of the original user physiological data and the original user basic data. The structure type includes structured data, semi-structured data and unstructured data. For example, information is extracted from health database reading (structured data), user voice or text input (unstructured data) and third-party applications (semi-structured data), such as small programs that come with weight scales or blood pressure monitors.

[0105] Specifically, in the preprocessing unit, the preprocessing includes data cleaning and data standardization. The data cleaning includes missing value processing, outlier processing, and duplicate data processing. The missing values ​​are processed by deletion or filling. The deletion method is suitable for situations where the missing values ​​account for a low proportion of the overall data, and the data records containing missing values ​​can be directly deleted. The filling method is suitable for numerical data, and the missing values ​​are filled by the mean, median, or mode. For categorical data, the missing values ​​are filled with the value that appears the most times. For example, for a user's weight data, if there are missing values, the average weight of the user at other measurement times can be used to fill them. When processing outliers, outliers are first identified through statistical methods or machine learning algorithms. The statistical method uses the degree of deviation from the mean as the criterion for judging outliers, and uses deletion or filling methods to correct outliers. The machine learning algorithm uses the isolation forest model to construct a recognition model to identify outliers. Duplicate data is identified by searching for duplicate records, and the duplicate data is directly deleted until only one record remains.

[0106] Specifically, the data normalization process is used to normalize data of different scales to the same scale, using Z-value normalization or maximum-minimum normalization. For example, Z-value normalization is used to convert heart rate data into a standard normal distribution with a mean of 0 and a standard deviation of 1. The preprocessing also includes categorical data encoding. For categorical data in multi-source basic data, such as gender, occupation, etc., an encoding method is used to convert them into numerical data. The encoding methods include one-hot encoding and label encoding. For example, for gender data, one-hot encoding can be used to encode "male" and "female" as [1,0] and [0,1] respectively.

[0107] Specifically, the portrait creation module includes:

[0108] a target data acquisition unit, configured to acquire the user's health target, input the user's health target into a pre-trained large language model, and obtain target data;

[0109] a feature extraction unit, configured to extract features from the target data, the user basic data, and the user physiological data to obtain a plurality of user features;

[0110] a label creation unit, configured to create a plurality of user labels according to the plurality of user characteristics;

[0111] A portrait generation unit is used to input a number of the user tags into the pre-trained large language model to obtain a user portrait.

[0112] Specifically, the feature extraction unit includes:

[0113] a classification subunit, configured to classify the target data, the user basic data, and the user physiological data according to data types, wherein the data types include structured data, semi-structured data, and unstructured data;

[0114] A first feature extraction subunit is configured to extract features from the target data, the user basic data, and the user physiological data, the classification results of which are structured data, according to statistical features, to obtain a plurality of first features;

[0115] A second feature extraction subunit is configured to extract features of the target data, the user basic data, and the user physiological data, the classification results of which are semi-structured data, by using a script object representation method to obtain a plurality of second features;

[0116] The third feature extraction subunit is used to extract features from the target data, the user basic data and the user physiological data whose classification results are unstructured data by using a natural language processing method to obtain a plurality of third features.

[0117] Specifically, the plurality of user characteristics include a first characteristic, a second characteristic and a third characteristic.

[0118] Specifically, the Scripting Object Representation (SOR) is a method for describing and organizing data structures, and is used to process semi-structured or complex data. It represents data in the form of scripted objects, making it easier to operate, access, and process the data. In this method, each data item is regarded as an object, containing properties and methods, which can flexibly map and represent data from different sources and formats. It is usually used to represent content without a strict table structure (such as JSON, XML, log files, etc.). Through the Scripting Object Representation, data can be extracted, processed, and transformed to adapt to a variety of different data sources and requirements. Semi-structured data uses regular expressions, XPath, or API tools to parse field values; unstructured data uses Natural Language Processing (NLP) technology, such as the Transformer-based BERT (Bidirectional Encoder Representations from Transformers) model, to extract text embedding features and combine sentiment analysis tools to refine semantic information. In addition, for unstructured media data such as pictures and videos, the system uses convolutional neural networks (CNN) to extract image features or key frame information in videos to ensure comprehensive coverage of multimodal features.

[0119] Specifically, in the label establishment unit, when establishing the user labels based on the user features, direct label extraction, cluster analysis, and classification algorithms can be used. The direct label extraction method directly extracts representative and discriminative information as user labels. For example, based on user features such as age, gender, and health goals, labels such as "young female weight loss user" and "middle-aged male hypertension patient" can be directly generated. The cluster analysis method uses the user features as input to a clustering algorithm, assigns a similarity value to each user feature, and clusters the user features based on the similarity values ​​to form a number of clusters, each corresponding to a user label. The clustering algorithm can use a K-means clustering algorithm or a density-based spatial clustering algorithm. For example, users with similar eating habits, exercise habits, and health goals can be clustered into a single category labeled "healthy living advocate." The classification algorithm uses a decision tree algorithm or a support vector machine algorithm to classify new users based on existing user label data and generate corresponding user labels. For example, a classification model can be trained using labeled user data. When new user data is input, the model can automatically assign appropriate user labels.

[0120] Specifically, in the portrait generation unit, the user tag is first fused with the knowledge and information in the large language model. The user tag is used as the input condition of the large language model, or the user tag is embedded in the parameters of the large language model, so that the large language model can generate content that is more in line with the user's personalized needs based on the user tag. Secondly, the large language model generates a user portrait based on the user tag. The user portrait not only includes the user's basic information and health goals, but also covers information in multiple dimensions such as the user's eating preferences, exercise habits, and health status, providing a comprehensive basis for the subsequent generation of personalized healthy diet plans. The user portrait is presented to relevant parties in an intuitive and easy-to-understand manner, such as the user himself, a nutritionist, a health manager, etc. The presentation method adopts structured data tables, visual charts, text descriptions, etc., which are convenient for users and professionals to view and understand.

[0121] Specifically, the solution generation module includes:

[0122] A portrait extraction unit, configured to obtain user portrait features based on the user portrait;

[0123] A nutrition feature extraction unit, configured to extract features from the nutrition database to obtain nutrition features;

[0124] A recommendation degree calculation unit, configured to input the nutritional features and the user profile features into a pre-trained multi-head attention model to obtain a recommendation degree for each nutritional feature;

[0125] A plan output unit is used to select several nutritional characteristics according to the recommendation degree and output them as dietary recommendation plans.

[0126] Specifically, the profile extraction unit extracts user profile features from the user profile. The user profile features include age, gender, height, weight, weight loss, muscle gain, health maintenance, preferred food types, tastes, exercise frequency, exercise type, blood sugar, blood pressure, and blood lipids. After the user profile features are extracted, they are standardized or normalized to facilitate subsequent computational processing. Alternatively, the user profile features may be subjected to dimensionality reduction to remove redundant information and improve processing efficiency and accuracy.

[0127] Specifically, in the nutritional profile extraction unit, the nutritional database is formed by integrating dietary nutrition literature, guidelines, and research results from multiple authoritative institutions. The nutritional profiles include food calories, protein content, fat content, carbohydrate content, vitamin and mineral content, etc. When extracting the nutritional profiles, a feature selection algorithm (e.g., principal component analysis or correlation analysis) is used for screening.

[0128] Specifically, in the recommendation degree calculation unit, by inputting the user portrait features and the nutritional features into the pre-trained multi-head attention model, a recommendation degree is generated for each nutritional feature through learning and calculation of multiple attention heads. These scores reflect the degree of matching and correlation between different nutritional features and user portrait features. According to the output of the multi-head attention model, the recommendation degree of each nutritional feature is calculated. The score can be normalized so that it falls within a specific interval (for example, between 0 and 1) to facilitate subsequent recommendation decisions. At the same time, the score can be adjusted and optimized according to actual conditions, such as fine-tuning based on user feedback or expert knowledge.

[0129] Specifically, in the solution output unit, all nutritional features are sorted according to the degree of recommendation, and nutritional features with a large degree of recommendation are preferentially selected as output features based on the sorting results. According to the output features, corresponding ingredients and cooking methods are screened from the nutritional database to form a dietary recommendation solution. The generated dietary recommendation solution is presented to the user in a clear and intuitive manner. It can be in the form of a recipe list, nutritional component analysis, diet plan table, etc., to facilitate user understanding and operation. At the same time, some relevant dietary suggestions and precautions can be provided to help users better implement the recommended solution and achieve their health goals.

[0130] It can be seen from the above embodiments that the present invention can provide users with personalized and dynamically adjustable healthy diet suggestions in actual scenarios, and can automatically generate explanations to help users understand and adopt them.

[0131] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.

[0132] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned diet recommendation methods based on a large language model.

[0133] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program, when executed by the processor, can implement the steps of the above-mentioned various method embodiments. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. Of course, there are other ways of readable storage media, such as quantum memory, graphene memory, etc. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practices in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practices, computer-readable media does not include electrical carrier signals and telecommunication signals.

[0134] The present invention also provides an electronic device. The electronic device in an embodiment of the present invention includes: one or more processors; and a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the dietary recommendation method based on a large language model provided by the present invention.

[0135] Reference below Figure 8 , which shows a schematic structural diagram of a computer system 800 of an electronic device suitable for implementing an embodiment of the present invention. Figure 8 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present invention.

[0136] like Figure 8 As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage unit 808 into a random access memory (RAM) 803. Various programs and data required for the operation of the computer system 800 are also stored in the RAM 803. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0137] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, and the like; an output section 807 including devices such as a cathode ray tube (CRT), a liquid crystal display (LCD), and a speaker; a storage section 808 including a hard disk; and a communication section 809 including a network interface card such as a LAN card or a modem. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, or a semiconductor memory, is installed in the drive 810 as needed, so that computer programs read therefrom can be installed in the storage section 808 as needed.

[0138] In particular, according to embodiments disclosed herein, the processes described in the main step diagrams above can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods shown in the main step diagrams. In the above embodiments, the computer program can be downloaded and installed from a network via the communication section 809 and / or installed from removable media 811. When the computer program is executed by the central processing unit 801, the above-described functions defined in the system of the present invention are performed.

[0139] It should be noted that the computer-readable medium described in the present invention may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to, an electrical connection having one or more conductors, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present invention, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. Program code embodied on a computer-readable medium may be transmitted using any suitable medium, including but not limited to wireless, wireline, optical cable, RF, or any suitable combination thereof.

[0140] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the above-mentioned module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0141] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.

Claims

1. A diet recommendation method based on a large language model, characterized in that: The following steps are involved: S10: Obtaining user basic data and user physiological data; S20: Obtaining a user health goal, and inputting the user health goal, the user basic data, and the user physiological data into a pre-trained large language model to obtain a user profile; S30: Inputting the preset nutrition database and the user portrait into a pre-trained multi-head attention model to generate a diet recommendation plan.

2. A diet recommendation method based on a large language model according to claim 1, characterized in that: In step S10, the following steps are included: S11: Obtaining original user physiological data and original user basic data from several data sources; S12: using a dynamic protocol adaptation method to identify the original user physiological data and the original user basic data to obtain multi-source physiological data and multi-source basic data; S13: Preprocessing the multi-source physiological data and the multi-source basic data to obtain user basic data and user physiological data.

3. The diet recommendation method based on a large language model according to claim 1, characterized in that: In step S20, the following steps are included: S21: Obtain the user's health goal, input the user's health goal into a pre-trained large language model, and obtain target data; S22: performing feature extraction on the target data, the user basic data, and the user physiological data to obtain a number of user features; S23: Creating a plurality of user tags based on the plurality of user characteristics; S24: Inputting the plurality of user tags into the pre-trained large language model to obtain a user portrait.

4. The diet recommendation method based on a large language model according to claim 1, characterized in that: In step S30, the following steps are included: S31: Obtaining user portrait features according to the user portrait; S32: extracting features from the nutrition database to obtain nutrition features; S33: Inputting the nutritional features and the user profile features into a pre-trained multi-head attention model to obtain the recommendation degree of each nutritional feature; S34: Selecting a number of the nutritional characteristics according to the recommendation degree as a dietary recommendation plan for output.

5. The diet recommendation method based on a large language model according to claim 1, characterized in that: The process further includes step S40, which specifically includes: Obtain feedback data from the user after a preset period of time following the dietary recommendation plan, and determine whether the health goal has been achieved based on the feedback data and the user's health goal. If it is determined that the health goal has not been achieved, adjust the parameters in the large language model and the multi-head attention model.

6. The diet recommendation method based on a large language model according to claim 3, characterized in that: The step S22 specifically includes the following steps: S221: Classifying the target data, the user basic data, and the user physiological data according to data types, where the data types include structured data, semi-structured data, and unstructured data; S222: extracting features from the target data, the user basic data, and the user physiological data, the classification results of which are structured data, according to statistical features to obtain a plurality of first features; S223: extracting features of the target data, the user basic data, and the user physiological data, the classification results of which are semi-structured data, using a script object representation method to obtain a plurality of second features; S224: extracting features from the target data, the user basic data, and the user physiological data, which are classified as unstructured data, using a natural language processing method to obtain a plurality of third features; The plurality of user characteristics include a first characteristic, a second characteristic, and a third characteristic.

7. The diet recommendation method based on a large language model according to claim 4, characterized in that: The multi-head attention model satisfies constraints, which include nutritional ingredient constraints, cooking method constraints, and dietary taboo constraints.

8. A diet recommendation system based on a large language model, characterized in that: include: Data acquisition module, used to obtain user basic data and physiological data; A portrait creation module is used to obtain a user's health goals and input the user's health goals, the user's basic data, and the physiological data into a pre-trained large language model to obtain a user portrait; A plan generation module is used to input the user portrait into the large language model to generate a diet recommendation plan.

9. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement a diet recommendation method based on a large language model as described in any one of claims 1 to 7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the diet recommendation method based on a large language model as described in any one of claims 1 to 7 is implemented.