E-commerce food risk assessment model construction method based on user evaluation
By constructing an e-commerce food risk assessment model, utilizing user reviews and product attribute data, and combining multi-head attention mechanisms and multi-task decision-making, the accuracy and efficiency issues of automated food safety risk assessment on e-commerce platforms were solved, achieving more efficient food safety risk identification.
Patent Information
- Application Number
- CN202511371377.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-24
- Publication Date
- 2025-12-26
AI Technical Summary
Existing technologies are insufficient for efficiently utilizing consumer reviews on e-commerce platforms to automatically identify food safety risks, and they suffer from misjudgments and incompleteness, making it impossible to accurately classify food safety risks.
An e-commerce food risk assessment model based on user reviews is constructed. By acquiring user review information and product attribute data, a feature relationship structure is defined, and a risk level generation model is generated by adopting a multi-head attention mechanism and multi-task decision-making. The food safety risk assessment is then carried out in combination with the feature relationship structure.
It improves the accuracy and efficiency of food safety risk assessment, reduces false positives and false negatives, and enables more accurate identification of complex food safety risks.
Smart Images

Figure CN121212903A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the application of natural language processing in the technical field of food safety supervision, in particular to a method for constructing an e-commerce food risk assessment model based on user evaluation. BACKGROUND
[0002] With the development of e-commerce platforms, food safety on e-commerce platforms is an important livelihood issue. However, current food safety monitoring and evaluation on e-commerce platforms mainly relies on source sampling and after-sales feedback. However, the sources of goods on e-commerce platforms are wide-ranging, making it difficult to accurately locate them, and after-sales feedback is not always timely or comprehensive. However, according to the transaction characteristics of e-commerce platforms, consumers will leave comments after purchasing food. These comments not only contain evaluations of the taste and packaging of the food, but also may involve food quality and safety issues, such as whether the food is expired, spoiled, or has an odor. Therefore, if consumer comment information can be efficiently utilized to automatically identify food safety and judge safety risks from a large number of comments, comprehensive food safety monitoring can be achieved.
[0003] In the prior art, food safety risk is judged by NLP based on order-logistics full-link data. In actual deployment, complete order information cannot be obtained due to privacy policies, making it inconvenient for regulatory authorities to implement. In terms of technical implementation, existing comment analysis methods mostly use traditional machine learning methods such as support vector machines (SVM) or random forests for sentiment analysis and classification. However, these methods cannot fully capture the deep semantics and temporal dependencies of comment text, ignore the characteristics of the goods themselves, and have problems such as misjudging "yogurt is too sour" as spoiled. Although some classification methods based on BERT can extract text semantic features, they still have limitations for multi-label classification tasks in long text. Evaluation information also has the defect of consumer subjective evaluation, which can easily misjudge the quality of goods. In addition, single text analysis methods do not make a graded judgment of food safety risks, and the model still needs manual judgment of food safety risks after multi-label classification.
[0004] Therefore, there is an urgent need for a method for constructing an e-commerce food risk assessment model based on user evaluation, which automatically analyzes food comments, integrates product attributes and e-commerce transaction characteristics, and makes a graded judgment of food safety risks to improve the automation of e-commerce food safety supervision. SUMMARY
[0005] To achieve the above-mentioned purpose, the present application provides a method for constructing an e-commerce food risk assessment model based on user evaluation, comprising the following steps: The process involves obtaining user reviews of food products from e-commerce platforms, filtering these reviews using keywords to create a set of food quality evaluations, and then categorizing the product attribute data from the e-commerce platform to form a set of food shelf-life characteristics. This set of characteristics includes environmental preservation requirements, susceptibility to damage, and shelf-life requirements. The food quality evaluation set is preprocessed to generate an e-commerce food quality evaluation feature set; the e-commerce food quality evaluation feature set includes evaluation features and labeled risk levels. Define a feature relationship structure and convert it into a vector; the feature relationship structure includes evaluation feedback features, food shelf-life features, occurrence time, and the influence relationship between food shelf-life features and evaluation feedback features; the occurrence time includes evaluation time and order generation time. An e-commerce food risk assessment model is constructed, including a risk level generation model and an optimized risk level generation model. The risk level generation model is trained by combining the food quality evaluation set and the feature relationship structure.
[0006] Among them, the evaluation feedback features are generated based on user evaluation information, and the food shelf life features are generated based on product attribute data.
[0007] The categories of evaluation feedback features include: features corresponding to consequences after user consumption, features corresponding to abnormal objective judgments by users, features corresponding to abnormal subjective judgments by users, and features corresponding to abnormal packaging and logistics.
[0008] The influence relationship between food shelf-life characteristics and evaluation feedback characteristics is used to limit the importance of evaluation feedback characteristics in reflecting food quality risks. This importance is determined based on the evaluation feedback characteristics, food shelf-life characteristics, and the time of occurrence.
[0009] Furthermore, when the feature relationship structure is converted into a vector, the influence relationship between food shelf-life features and evaluation feedback features is expressed as follows: M = f(A) ⊙ σ(1 - α·con(A,B, C)), where: M is the importance level vector, A is the vector of evaluation feedback features, B and C are the vectors of food shelf life features and occurrence time, respectively, f(A) is the basic mapping function from evaluation feedback features to the importance of food quality risk, con(A,B, C) is the logical judgment function of influence relationship, α is the adjustment strength parameter and 0<α<1, σ is the sigmoid function, and ⊙ is element-wise multiplication; When con(A,B, C)=1, adjust the weight σ(1-α) to reduce the importance of the evaluation feedback features in reflecting food quality risks; When con(A, B, C) = 0, the weight σ(1) is adjusted to keep the evaluation feedback feature reflecting the importance of the food quality risk.
[0010] The influence relationship between the food shelf-life feature and the evaluation feedback feature includes: If the evaluation feedback feature includes a packaging logistics abnormality feature, it is determined whether the food shelf-life feature includes an environmental preservation requirement and a property of being easy to be damaged by collision, and if so, the importance of the evaluation feedback feature in reflecting the food quality risk is reduced. If the evaluation feedback feature includes a user objective judgment abnormality corresponding feature, it is determined whether the food shelf-life feature includes a storage time requirement, and whether a time difference between an evaluation time and an order generation time meets the storage time requirement, and if not, the importance of the evaluation feedback feature in reflecting the food quality risk is reduced. If the evaluation feedback feature is a user subjective judgment abnormality corresponding feature, it is determined whether the food shelf-life feature includes an environmental preservation requirement and a storage time requirement, and if so, the importance of the evaluation feedback feature in reflecting the food quality risk is reduced.
[0011] Further, the preprocessing includes: removing HTML tags, special characters, and emoticons from the food quality evaluation set, and removing common but semantically insignificant stop words; obtaining label risk level information corresponding to each evaluation in the food quality evaluation set, and reconstructing the structure of the food quality evaluation set, including: evaluation features and label risk levels; performing word segmentation processing on the evaluation features; and converting the e-commerce food quality evaluation feature set into a vector set to constitute the evaluation features in the e-commerce food quality evaluation feature set.
[0012] The risk level generation model includes the following steps: The evaluation information associated with the food expiration related features is obtained through feature extraction; The attention distribution between different features in the e-commerce food quality evaluation feature set is calculated using a multi-head attention mechanism, the feature relationship structure vector is combined, the feature expression capability is improved through weighted fusion, and the outputs of different feature channels are weighted and summed. The food risk level probability is output through multi-task decision. The loss function is defined to realize weighted cross-entropy loss, and the weight adjustment is performed for the class imbalance problem of different labels.
[0013] The risk level generation model is optimized to train and verify the data set of the food quality evaluation set, and the e-commerce food risk evaluation model is trained and optimized in combination with the feature relationship structure to generate the e-commerce food risk evaluation model.
[0014] The application fully taps the data generated by e-commerce platform transactions, defines a feature relationship structure in combination with the features of e-commerce platforms, commodities and user comments, integrates multi-model fusion, and can more quickly judge the food safety risk level and improve the food safety monitoring efficiency. Compared with a single model method, the accuracy is improved on the food safety risk evaluation task by the method provided by the application. Meanwhile, since the feature relationship structure fully considers the features of the commodity itself, combines the influence of logistics and environment, and limits the subjective judgment of the user, the result of risk evaluation is more accurate. BRIEF DESCRIPTION OF DRAWINGS
[0015] Figure 1 is a construction method of an e-commerce food risk evaluation model provided by an embodiment of the application; Figure 2 is an e-commerce food risk evaluation feature relationship structure diagram provided by an embodiment of the application. DETAILED DESCRIPTION
[0016] The application classifies the features of food commodities on an e-commerce platform, judges whether the food has quality problems including expiration, deterioration or hidden dangers caused by logistics in combination with the consumer comment information corresponding to the commodities, objectively evaluates the food in multiple dimensions, and realizes effective control of the food quality.
[0017] The specific implementation of the application will be described in detail below with reference to the accompanying drawings.
[0018] The construction method of the e-commerce food risk evaluation model provided by the application is as shown in Figure 1 , and includes the following steps: Step S100: original information acquisition; including obtaining user evaluation information of e-commerce food, screening the user evaluation information through keywords, and obtaining a food quality evaluation set; The user evaluation information is the information feedback of consumers after purchase on an e-commerce platform, for example, a consumer's evaluation of a batch of yogurt is "ice bag has melted"; the commodity, the evaluation time, the order generation time and the evaluation of the commodity constitute a feedback information; and multiple feedback information constitutes a food quality evaluation set.
[0019] Meanwhile, the commodity attribute data of the e-commerce platform is obtained: including commodity category, commodity taste characteristics, shelf life and storage requirements and the like; for example, the commodity category is yogurt, the commodity taste characteristics include sour and rich, the shelf life is 7 days, and the storage requirement is cold storage; the commodity attribute data is classified to constitute a food shelf life feature set, and the content of the food shelf life feature set includes environmental preservation requirements, easy-to-damage attributes and storage time requirements.
[0020] Step S110: pre-processing the food quality evaluation set to generate an e-commerce food quality evaluation feature set; The e-commerce food quality evaluation feature set includes evaluation features and labeled risk levels; the evaluation features are generated by pre-processing the food quality evaluation set.
[0021] During pre-processing, first, remove HTML tags, special characters, and emoticons from the food quality evaluation set, remove common but semantically insignificant stop words such as "of", "was", "in", etc. to ensure data normalization; second, obtain the labeled risk level information corresponding to each evaluation in the food quality evaluation set, and reconstruct the structure of the food quality evaluation set. The reconstructed structure includes evaluation features and labeled risk levels; third, perform word segmentation on the evaluation features using the Jieba word segmentation tool to optimize Chinese text input; fourth, use a pre-trained Word2Vec model to convert the segmented text into a word vector, converting the e-commerce food quality evaluation feature set into a vector set, and constructing the evaluation features in the e-commerce food quality evaluation feature set.
[0022] In this step, the labeled risk level is generated by artificial labeling combined with semi-artificial labeling based on the definition of risk level.
[0023] In the present application, the risk level is defined according to the degree of influence of food quality, including: First, the food directly related to personal safety in the comment features, including "poisoning", "diarrhea"; Second, the food that can be directly and explicitly expired in the comment features, including "expired" and the like; Third, the food that reflects food spoilage in the comment features, but is caused by time, environment, logistics, etc. Fourth, the comment features that reflect the characteristics of the environment in which the food is placed, such as package damage, surface dirt, package leakage, etc.
[0024] In practical applications, these four risk levels are not independent and have a certain degree of mutual influence; for example, package damage at the fourth level may cause food spoilage at the third level, which in turn may cause diarrhea. However, the final impact of the food sold also needs to be judged by the user's evaluation of the food.
[0025] On the other hand, the content of the user's evaluation of the food has a certain subjectivity, or does not reflect the quality problem of the food itself, such as logistics impact, user overage storage, etc. Therefore, when analyzing the food risk, it is also necessary to consider the environmental information reflected in the evaluation.
[0026] Therefore, in the present application, the feature relationship structure is defined to provide a multi-dimensional judgment standard for risk assessment of the food.
[0027] Step S120: defining the feature relationship structure; As Figure 2 shown, the feature relationship structure includes evaluation feedback features, food shelf life features, and occurrence times; the occurrence times include evaluation times and order generation times. The evaluation feedback features are classified according to user evaluation information of each commodity on the e-commerce platform, and the food shelf life features are classified according to commodity attribute data. The food shelf life features specifically include commodity features, environmental preservation requirements, easy-to-damage attributes, and storage time requirements. The commodity features provide the characteristics of the food in terms of color vision, taste, etc., for example, the commodity features of yogurt are "rich, sour, and sweet"; the environmental preservation requirement is "2-6℃"; the storage time requirement is "7 days"; and if the commodity is packaged in glass, it has an easy-to-damage attribute.
[0028] The evaluation feedback features are features related to food reflected from a food quality evaluation set, and the categories include: user consumption consequences corresponding features, user objective judgment abnormalities corresponding features, user subjective judgment abnormalities corresponding features, and packaging logistics abnormalities corresponding features. The feature relationship structure also includes the influence relationship between the food shelf life features and the evaluation feedback features; the influence relationship is used to limit the importance of the evaluation feedback features in reflecting food quality risks, and the importance is determined according to the evaluation feedback features, the food shelf life features, and the occurrence times.
[0029] The influence relationship specifically includes: If the evaluation feedback features include packaging logistics abnormal features, it is determined whether the food shelf life features include environmental preservation requirements and easy-to-damage attributes; if so, the importance of the evaluation feedback features in reflecting food quality risks is reduced. If the evaluation feedback features include user objective judgment abnormality corresponding features, it is determined whether the food shelf life features include storage time requirements, and whether the time difference between the evaluation time and the order generation time meets the storage time requirements; if not, the importance of the evaluation feedback features in reflecting food quality risks is reduced. If the evaluation feedback features are user subjective judgment abnormality corresponding features, it is determined whether the food shelf life features include environmental preservation requirements and storage time requirements; if so, the importance of the evaluation feedback features in reflecting food quality risks is reduced.
[0030] Further, the feature relationship structure is converted into a vector, and the influence relationship between the food shelf life features and the evaluation feedback features is represented as: M = f(A) σ(1 - a con(A, B, C)), wherein: M is a degree of importance vector, A is a vector of evaluation feedback features, B and C are vectors of food quality features and occurrence time respectively, f(A) is a basic mapping function of evaluation feedback features to the importance of food quality risk, con(A, B, C) is a logical judgment function of influence relationship, a is an adjustment intensity parameter and 0 < a < 1, σ is a sigmoid function, and is an element-wise multiplication; When con(A, B, C) = 1, the adjustment weight σ(1 - a) is reduced to reduce the importance of the evaluation feedback feature reflecting the food quality risk; When con(A, B, C) = 0, the adjustment weight σ(1) is maintained to maintain the importance of the evaluation feedback feature reflecting the food quality risk.
[0031] Step S130: Constructing an e-commerce food risk assessment model: The construction of the e-commerce food risk assessment model includes generating a risk level generation model and optimizing the risk level generation model; Step S131: Generating a risk level generation model: This process specifically includes feature extraction, multi-head attention mechanism fusion, feature fusion, multi-task decision module, and loss function design; 1) In feature extraction, global feature extraction is performed by LLaMA 7B model to obtain global semantic features of user evaluation information; local feature extraction is performed by BERT model to obtain local semantic features of comment text; bidirectional LSTM is used to capture the timing features and emotional changes of the comment text; finally, the evaluation information associated with the food expiration related features such as "expired", "spoiled", "odor" and the like is obtained.
[0032] 2) Multi-head attention mechanism fusion: Multi-Head Attention (MHA) mechanism is used to calculate the attention distribution between different features in the set of e-commerce food quality evaluation features, combine the feature relationship structure vector, and enhance the feature expression ability through weighted fusion; adaptive weight mechanism is used to weight and sum the outputs of different feature channels to enhance the generalization ability of the model; 3) Multi-task decision: the input feature vector, the influence relationship between food quality features and evaluation feedback features are fused by using full connection layer, and the dimension is reduced by using multi-layer perception (MLP) structure; wherein, the food expiration related feature associated evaluation information can be comprehensively judged by using food quality features; ReLU activation function is used for multi-label classification; through the output layer: output the food "first level", "second level", "third level", "fourth level" risk probability; 4) Define the loss function to realize the weighted cross-entropy loss, adjust the weight for the class imbalance problem of different labels, and enhance the discrimination ability of different classes through contrastive loss; realize attention alignment loss to ensure that the weight distribution is reasonable in the feature fusion process of different models.
[0033] Step S132: When optimizing the risk level generation model, batch training is used to improve training efficiency; the Adam optimizer is used for gradient update to ensure fast convergence of the model; finally, the model performance is evaluated through cross-validation, and the hyperparameters are optimized.
[0034] In the stage of generating the risk level generation model, the data of the food quality evaluation set is distributed, for example, 80% for training and 20% for verification, and after inputting the e-commerce food risk assessment model, the e-commerce food risk assessment model is trained and optimized combined with the feature relationship structure, and the e-commerce food risk assessment model is constructed.
[0035] The test environment for performing this step uses the PyTorch deep learning framework, in terms of evaluation indicators, the accuracy is set to measure the overall classification accuracy of the model, the F1-score is used as an evaluation indicator of comprehensive precision and recall, and the precision and recall are used to measure the detection ability of the model on the food expiration problem.
[0036] Step S140: The e-commerce food risk assessment model generated by defining and iteratively training in step S130 can be used in the e-commerce platform food safety risk intelligent grading method and evaluation system, and the preprocessed evaluation information of the user on the food is input into the e-commerce food risk assessment model, so as to obtain the quality risk level of the corresponding food.
[0037] The e-commerce food risk assessment model constructed by the method provided by the present application has an F1-score improvement of 12.5% compared with the commonly used single model method (such as using only BERT), and the recall rate is significantly improved in the food safety risk judgment task, reducing false positives and false negatives; at the same time, the multi-model fusion and multi-head attention mechanism combined with the feature relationship structure enable the system to identify more complex food safety risks, such as accurately identifying "storage caused by deterioration" or "secondary sales of expired food".
[0038] The above disclosure is only a few specific embodiments of the present application, but the present application is not limited thereto, and any changes that can be thought of by those skilled in the art shall fall within the protection scope of the present application.
Claims
1. A method for constructing an e-commerce food risk assessment model based on user reviews, characterized in that, The method comprises the following steps: Obtaining user evaluation information of an e-commerce food, screening the user evaluation information through keywords, and obtaining a food quality evaluation set; Obtaining commodity attribute data of an e-commerce platform, classifying the commodity attribute data, and constituting a food quality guarantee feature set; The content of the food quality guarantee feature set includes environmental preservation requirements, easy-to-damage attributes, and storage time requirements; Preprocessing the food quality evaluation set to generate an e-commerce food quality evaluation feature set; the e-commerce food quality evaluation feature set includes evaluation features and labeled risk levels; Defining a feature relationship structure and converting the feature relationship structure into a vector; the feature relationship structure includes evaluation feedback features, food quality guarantee features, occurrence times, and influence relationships between the food quality guarantee features and the evaluation feedback features; the occurrence times include evaluation times and order generation times; Building an e-commerce food risk assessment model, including generating a risk level generation model and optimizing the risk level generation model, combining the food quality evaluation set and the feature relationship structure, and training the risk level generation model. 2.The method of claim 1, wherein, The evaluation feedback features are generated according to the classification of the user evaluation information, and the food quality guarantee features are generated according to the classification of the commodity attribute data. 3.The method of claim 1, wherein, The categories of the evaluation feedback features include consequences corresponding to user consumption, user objective judgment abnormalities, user subjective judgment abnormalities, and packaging logistics abnormalities. 4.The method of claim 1, wherein, The influence relationship between the food quality guarantee features and the evaluation feedback features is used to limit the importance of the evaluation feedback features in reflecting food quality risks, and the importance is determined according to the evaluation feedback features, the food quality guarantee features, and the occurrence times.
5. The method of claim 4, wherein, When converting the feature relationship structure into a vector, the influence relationship between the food quality guarantee features and the evaluation feedback features is represented as: M = f(A) ⊙ σ(1 - α·con(A,B, C)), where M is a level vector of importance, A is a vector of evaluation feedback features, B and C are vectors of food quality guarantee features and occurrence times respectively, f(A) is a basic mapping function of evaluation feedback features to the importance of food quality risks, con(A,B, C) is a logical judgment function of the influence relationship, α is an adjustment intensity parameter and 0 < α < 1, σ is a sigmoid function, and ⊙ is an element-wise multiplication; When con(A,B, C) = 1, the adjustment weight σ(1-α) is reduced to reduce the importance of the evaluation feedback features in reflecting food quality risks; When con(A,B, C) = 0, the adjustment weight σ(1) is maintained to maintain the importance of the evaluation feedback features in reflecting food quality risks.
6. The method of claim 5, wherein, The influence relationship between the food quality guarantee features and the evaluation feedback features includes: If the evaluation feedback features include packaging logistics abnormal features, it is determined whether the food quality guarantee features include environmental preservation requirements and easy-to-damage attributes, and if so, the importance of the evaluation feedback features in reflecting food quality risks is reduced. If the evaluation feedback feature includes a user objective judgment abnormality corresponding feature, it is judged whether the food shelf-life feature includes a storage time requirement, and whether the time difference between the evaluation time and the order generation time meets the storage time requirement. If not, the importance of the evaluation feedback feature reflecting the food quality risk is reduced; If the evaluation feedback feature is a user subjective judgment abnormality corresponding feature, it is judged whether the food shelf-life feature includes an environmental preservation requirement or a storage time requirement. If so, the importance of the evaluation feedback feature reflecting the food quality risk is reduced. 7.The method of claim 1, wherein, The preprocessing includes: removing HTML tags, special characters, and emoticons from the food quality evaluation set, and removing common but semantically insignificant stop words; obtaining label risk level information corresponding to each evaluation in the food quality evaluation set, and reconstructing the structure of the food quality evaluation set, including: evaluation features and label risk levels; performing word segmentation processing on the evaluation features; converting the e-commerce food quality evaluation feature set into a vector set to constitute the evaluation features in the e-commerce food quality evaluation feature set. 8.The method of claim 1, wherein, The generation of the risk level generation model includes the following steps: Obtain evaluation information associated with food expiration-related features through feature extraction; Use a multi-head attention mechanism to fuse the attention distribution between different features in the e-commerce food quality evaluation feature set, combine feature relationship structure vectors, and improve feature expression ability through weighted fusion. The outputs of different feature channels are weighted and summed; Output the food risk level probability through multi-task decision; Define a loss function to realize weighted cross-entropy loss and adjust the weights for the class imbalance problem of different labels. 9.The method of claim 1, wherein, The optimized risk level generation model trains and validates the data set of the food quality evaluation set, combines the feature relationship structure to train and optimize the e-commerce food risk assessment model, and generates the e-commerce food risk assessment model.
