A Smart Recommendation Method for Cosmetic Formulations Based on Ingredient Preferences

By constructing a four-tuple structured knowledge graph and improving the BERT-CRF algorithm, combined with the Transformer decoder, accurate recommendations for cosmetic formulas were achieved, solving the problems of low efficiency and insufficient matching accuracy in traditional methods, and ensuring the compliance and personalized matching of formulas.

CN122309763APending Publication Date: 2026-06-30JINAN MEIJU INTERNET TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
JINAN MEIJU INTERNET TECH CO LTD
Filing Date
2026-04-03
Publication Date
2026-06-30

AI Technical Summary

Technical Problem

Traditional cosmetic formulation recommendations rely on the experience of R&D personnel, which is inefficient, lacks matching accuracy, makes it difficult to adapt to diverse user needs on a large scale, and makes it difficult to balance formulation compliance and personalized matching, thus failing to meet the technical requirements for accurate recommendations.

Method used

We construct a four-tuple structured knowledge graph for cosmetic formulation, combine knowledge graph embedding with Transformer decoder, add a knowledge-constrained attention branch, collect explicit and implicit preference data, and perform structured parsing using an improved BERT-CRF algorithm to generate formulation schemes that match user ingredient preferences.

Benefits of technology

It achieves precise matching of cosmetic formulas, ensures formula compliance and knowledge credibility, reduces the risk of fictitious ingredients and illegal proportions, and improves the efficiency and accuracy of recommendations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122309763A_ABST
    Figure CN122309763A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of intelligent recommendation technology, and particularly relates to an intelligent recommendation method for cosmetic formulas based on ingredient preferences. The method first constructs a structured cosmetic formula domain knowledge graph containing four tuples: entities, relationships, attributes, and constraints. Then, it builds a large-scale cosmetic formula domain model with a built-in knowledge graph embedding layer and a Transformer decoder with knowledge-constrained attention branches. It collects explicit and implicit user preference text data, performs structured parsing using an improved BERT-CRF algorithm, and obtains a standardized preference dataset. Finally, it inputs the dataset into the large-scale domain model to generate cosmetic formula solutions that match user ingredient preferences and meet compliance standards. This invention effectively improves the accuracy and efficiency of formula recommendation, balancing personalized needs and compliance, and achieving accurate and efficient cosmetic formula recommendations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of intelligent recommendation technology, and in particular relates to an intelligent recommendation method for cosmetic formulas based on ingredient preferences. Background Technology

[0002] With the popularization of personalized skincare concepts, cosmetic consumption is shifting from generic products to customized formulas with precise ingredient matching and efficacy. Users' needs for skin type matching, ingredient preferences, and appropriate usage scenarios are becoming increasingly segmented. Traditional cosmetic formula recommendations rely on the experience of R&D personnel, which is inefficient, lacks matching accuracy, struggles to scale up to meet diverse user needs, and fails to balance formula compliance with personalized matching. It cannot meet the technical requirements for accurate recommendations, and the industry urgently needs intelligent technologies to achieve accurate and efficient formula recommendations. Summary of the Invention

[0003] To address the technical problems existing in the background art described above, this invention proposes a method for intelligent recommendation of cosmetic formulations based on ingredient preferences.

[0004] To achieve the above objectives, the technical solution adopted by the present invention includes the following steps:

[0005] S1. Construct a knowledge graph for the cosmetic formulation field with a four-tuple structure;

[0006] S2. Construct a large model for cosmetic formulation, which includes a built-in knowledge graph embedding layer and a Transformer decoder with knowledge-constrained attention branches. After full decoding, the model outputs the formulation generation result.

[0007] S3. Collect users' explicit and implicit preference text data, and perform structured parsing using an improved BERT-CRF algorithm to obtain a structured preference text dataset;

[0008] S4. Input the structured preference text dataset into the large model of cosmetic formulation to generate a formulation scheme that matches the user's ingredient preferences.

[0009] Preferably, the quadruple in step S1 is a structure of entity, relation, attribute and constraint, wherein the entity includes cosmetic raw materials, efficacy, skin type and usage scenario, the relation includes synergistic, compatibility and contraindication relationships between raw materials, the attribute includes the physicochemical parameters and concentration range of the raw materials, and the constraint includes user allergy contraindications and raw material usage restrictions.

[0010] Preferably, the specific implementation of constructing a four-tuple-structured knowledge graph in the field of cosmetic formulation is as follows:

[0011] S11. Construct a standardized ontology library specifically for the cosmetics field, and perform word segmentation, noise reduction, and entity linking on unstructured and semi-structured text data from various data sources to generate a standardized corpus.

[0012] S12. Taking the complete efficacy transmission link of cosmetic formula raw material entity, efficacy entity, skin type entity and scene entity as the core framework, the entity set E of each node in the link and the attribute set P deeply bound to the entity are extracted from the standardized corpus to generate entity attribute binding unit.

[0013] S13. Using entity attribute binding units as nodes and efficacy transmission links as paths, calculate the relationship confidence weight between adjacent entity pairs in the link. The relationship confidence weight is obtained by normalizing and fusing the correlation strength of experimental data and literature evidence. Bind the calculated relationship confidence weight with the corresponding entity pair and relationship type to generate a relationship set R.

[0014] S14. Bind the constraints to the corresponding entities and relations in two directions to form a deeply coupled constraint set C, and finally obtain a quadruple structure of entities, relations, attributes and constraints.

[0015] S15. Based on quadruples, with constraints as topological boundaries and relation confidence weights as topological edge weights, construct a knowledge graph topology for the cosmetic formulation domain. Simultaneously, design a dynamic topology update function to dynamically adjust the topology and edge weights based on new data and constraint rules. The calculation method is as follows: ,in, This is the updated knowledge graph topology. For the current topology, To retain the constraint matrix, only topological nodes and edges that conform to the constraint rules are retained. To add topological increments corresponding to the new quadruples, The confidence level filtering matrix retains only newly added topological edges whose confidence weights are higher than a preset threshold. The Hadamard product operation is performed to ultimately complete the construction of the knowledge graph.

[0016] Preferably, in step S2, a large model for cosmetic formulation is constructed, and the knowledge graph embedding layer is:

[0017] The quadruple-structured domain knowledge graph is transformed into a knowledge embedding vector with the same dimension as the word embedding space of the large model. The TransH translation model is used to embed the quadruple-structured domain knowledge graph, mapping entities, relations, attributes and constraints into knowledge vectors of fixed dimensions. Then, the knowledge vectors are projected to a vector space with the same dimension as the word embedding vector of the large model through a fully connected linear projection layer, generating a standardized knowledge embedding vector.

[0018] Preferably, in step S2, a large model for cosmetic formulation is constructed. The Transformer decoder with knowledge-constrained attention branches is implemented by adding knowledge-constrained attention branches to each attention module of the Transformer decoder in the large model. These knowledge-constrained attention branches run in parallel with the decoder's self-attention branches and cross-attention branches, integrating knowledge embedding vectors into the token generation and reasoning process of each layer. This achieves deep alignment between the knowledge graph and the Transformer attention mechanism. Specifically, the implementation is as follows:

[0019] S221. Obtain the input hidden state vector H of the current Transformer decoder layer, and the pre-generated knowledge embedding vector matrix. ;

[0020] S222, Calculate the knowledge-constrained attention weight matrix: ,in, For the knowledge-constrained attention weight matrix, The dimension of the knowledge embedding vector;

[0021] S223. Calculate the knowledge-constrained output vector based on the knowledge-constrained attention weight matrix: and output the knowledge constraint vector. The output vectors of the self-attention branch and cross-attention branch in the same layer are concatenated, and then the dimensionality transformation and feature fusion are performed through a linear fusion layer to output the final hidden state vector of the current Transformer decoder layer.

[0022] Preferably, in step S3, the explicit preference text data includes the user's directly input target efficacy, raw material preferences, and post-use scenario needs data; the implicit preference text data includes the user's historical browsing of cosmetic formula-related content, past evaluation feedback of cosmetics used, and formula selection record data.

[0023] Preferably, step S3, which uses an improved BERT-CRF algorithm for structured parsing to obtain a structured preference text dataset, is implemented as follows:

[0024] S31. Perform preprocessing on the input full text data, including cleaning, word segmentation, and length normalization, to convert the text into a fixed-length token sequence, denoted as... Where n is the preset fixed length of the token sequence, It is the i-th token in the sequence;

[0025] S32. Generate word-level semantic embeddings, phrase-level semantic embeddings, and sub-word-level semantic embeddings for the token sequence, respectively. Use an adaptive gating mechanism to achieve dynamic fusion of multi-granularity embeddings and generate the final input embedding matrix.

[0026] S33. Construct an improved BERT encoding layer to complete the global semantic encoding of the input text and generate a multi-dimensional fused semantic feature matrix. The improved BERT encoding layer is composed of stacked encoding blocks with the same L-layer structure. Each encoding block undergoes decoupled dual-path multi-head attention computation. The decoupled dual-path multi-head attention computation involves setting parallel content semantic attention branches and position-dependent attention branches to independently model the semantic association and position dependency of the input features, respectively. After computation, the branches are dynamically fused to obtain the dual-path attention output. ;

[0027] S34, regarding the first Raw input of layer coded block The result of dual-path attention calculation As input, residual normalization and gated feedforward transformation are performed. First, identity residual fusion and layer normalization calibration are completed for the two inputs. Then, feature nonlinear transformation and key information filtering are completed through a gated feedforward network. Finally, residual fusion and layer normalization are performed again to output the first... The final hidden state matrix of the layer coded block ;

[0028] S35. After completing the stacking calculation of the L-layer coding blocks, the set of hidden state matrices of all layers is obtained. Layer normalization pre-calibration is performed on the features of all layers. Then, the adaptive fusion weights of each layer are learned through a hierarchical attention mechanism. After completing the multi-layer weighted fusion, residual optimization and final calibration are performed in combination with deep features to output a global semantic feature matrix adapted to the structured parsing task. ;

[0029] S36. Input the global semantic feature matrix into the CRF decoding layer, decode and output the optimal label sequence, complete information extraction and structured mapping, and generate a standardized structured preference text dataset.

[0030] Preferably, step S33 is implemented as follows:

[0031] S331, regarding the first A layer coding layer whose input is the hidden state output from the previous layer. The first-level input is the embedding matrix E generated in the previous step, which generates query, key, and value matrices for two branches, including a content semantic attention branch: , , Location-dependent attention branch: , , ;in, These are the linear mapping weight matrices for the content semantic branches. These are the linear mapping weight matrices for the position-dependent branches;

[0032] S332. Calculate the multi-head attention output and content semantic attention output for the two branches respectively, and calculate the attention weights based solely on semantic similarity, removing the interference of location information: The single-head attention calculation is as follows: Where h is the number of attention heads, The dimension of the single-headed key matrix. The content branch is fused with a weight matrix; the position-dependent attention output calculates attention weights based solely on relative positional relationships, removing semantic content interference. The single-head attention calculation is as follows: ,in, This is a relative position encoding matrix. This is the position branch weight matrix;

[0033] S333. Calculate the dynamic weight matrix of the two branch outputs to complete the attention output fusion: , ,in It is the Sigmoid activation function. This is the weight matrix. For bias terms, For the adaptive fusion weights of content semantic branches, This is the final output of dual-path attention.

[0034] Compared with the prior art, the advantages and positive effects of the present invention are as follows:

[0035] 1. Construct a structured knowledge graph of entities, relationships, attributes, and constraints, deeply bind rigid rules, take the efficacy transmission link as the core framework, calculate the confidence weight of relationships by combining experimental data and literature evidence, and support dynamic topology updates. This ensures the compliance and credibility of the formula from the root, and solves the problems of traditional knowledge being fragmented, unconstrained, and easily outdated.

[0036] 2. By deeply integrating knowledge graph embedding with Transformer decoder and adding knowledge-constrained attention branches, domain knowledge is incorporated into each layer of token generation reasoning. This ensures that the entire formula generation process is constrained by professional knowledge and compliance rules, significantly reducing issues such as fictitious ingredients and illegal proportions in large models. The output formula accurately matches ingredient preferences and fully meets the standards.

[0037] 3. Collect explicit and implicit preference data, and improve the BERT-CRF algorithm to achieve multi-granular semantic embedding, decoupled dual-path attention, and hierarchical weighted fusion, so as to accurately extract and structure user needs. Attached Figure Description

[0038] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0039] Figure 1 This is a schematic diagram illustrating the technical steps of a smart recommendation method for cosmetic formulations based on ingredient preferences. Detailed Implementation

[0040] To better understand the above-mentioned objectives, features, and advantages of the present invention, the present invention will be further described below in conjunction with the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features described in these embodiments can be combined with each other.

[0041] Numerous specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways than those described herein, and therefore the invention is not limited to the specific embodiments disclosed in the following specification.

[0042] In this embodiment, considering that existing traditional cosmetic formula recommendations rely on the experience of R&D personnel, resulting in low efficiency, insufficient matching accuracy, and difficulty in scaling up to meet diverse user needs, this embodiment provides an implementation process for an intelligent cosmetic formula recommendation method based on ingredient preferences. Figure 1 As shown.

[0043] First, a four-tuple-structured knowledge graph for cosmetic formulation is constructed, along with a symbolic rigid rule engine that maps and links with the knowledge graph. Specifically, the four-tuple is a structure of entities, relations, attributes, and constraints. Entities include cosmetic raw materials, efficacy, skin type, and usage scenarios; relations include synergistic, compatibility, and contraindications among raw materials; attributes include the physicochemical parameters and concentration ranges of raw materials; and constraints include user allergies and restrictions on the use of raw materials.

[0044] Furthermore, the implementation of the knowledge graph involves: constructing a standardized ontology library specifically for the cosmetics industry; performing word segmentation, noise reduction, and entity linking on unstructured and semi-structured text data from various data sources to generate a standardized corpus. Specifically, based on standards, a hierarchical standardized ontology library specifically for the cosmetics industry is constructed. The ontology library sets up a top-level ontology and sub-branches. The top-level ontology is divided into five categories: raw materials, efficacy, skin type, usage scenarios, and compliance constraints. Each category has sub-levels. For example, the raw materials ontology is subdivided into 12 second-level branches such as moisturizers, active ingredients, preservatives, and emulsifiers. The efficacy ontology corresponds to 26 standard efficacy claims such as whitening, moisturizing, anti-aging, and repair as stipulated by regulations. The skin type ontology corresponds to the five basic skin types of dry, oily, combination, sensitive, and normal skin, as well as their sub-subcategories, ensuring the compliance and industry universality of the ontology library. Secondly, multi-source heterogeneous data sources were collected, including full-ingredient formula data for cosmetics, core journal articles in the cosmetics field, publicly available formula-related invention patents, official technical manuals from raw material manufacturers, and raw material efficacy experimental data released by authoritative institutions. All unstructured and semi-structured text data underwent preprocessing: word segmentation was performed using a word segmentation tool; regular expression filtering was used to remove special symbols, irrelevant advertising text, and redundant content for noise reduction; then, entity linking technology was used to map extracted non-standard entities to standard entities in the ontology library, for example, mapping "hyaluronic acid" to the standard entity "sodium hyaluronate," while simultaneously performing entity disambiguation to resolve synonymy and homonymy issues. Finally, a standardized corpus conforming to the ontology library specifications was generated. The corpus was pre-annotated with entities and attributes using the BIO annotation system, providing standardized foundational data for subsequent entity, relation, and attribute extraction.

[0045] Using a complete efficacy transmission chain of cosmetic formulation entities, including raw material entities, efficacy entities, skin type entities, and scenario entities, as the core framework, this method simultaneously extracts entity sets E and attribute sets P deeply bound to each entity from a standardized corpus, generating entity attribute binding units. Specifically, based on the core logic of cosmetic formulations, a standardized efficacy transmission chain framework is defined. The chain starts with the user scenario, passes through skin type adaptation nodes and efficacy requirement nodes, and finally lands at the raw material implementation node, forming a complete transmission chain and avoiding chain breaks and logical disconnects caused by isolated entity extraction. Secondly, based on a pre-trained cosmetic domain entity extraction model, the method simultaneously extracts the entity sets E corresponding to each node along the efficacy transmission chain from the standardized corpus: for raw material nodes, it extracts standard raw material entities conforming to naming conventions; for efficacy nodes, it extracts standard efficacy entities conforming to naming conventions; for skin type nodes, it extracts skin type entities defined by industry standards; and for scenario nodes, it extracts scenario entities covering all scenarios such as daily care, post-medical aesthetic procedures, and special populations. Simultaneously, the attribute sets P deeply bound to each entity are extracted. Finally, each entity is uniquely bound to its corresponding full set of attributes, generating an entity attribute binding unit with a unique identifier to ensure a strong association between entities and attributes and avoid problems such as attribute mismatch and entity-attribute disconnection.

[0046] Using entity attribute binding units as nodes and efficacy transmission links as paths, the relationship confidence weights between adjacent entity pairs in the link are calculated. These relationship confidence weights are obtained by normalizing and fusing the correlation strength of experimental data and literature evidence. The calculated relationship confidence weights are then bound to the corresponding entity pairs and relationship types to generate a relationship set R. Specifically, based on the efficacy transmission link, adjacent entity pairs are paired, and the relationship types between nodes in the link are clarified. Core relationship types include: synergistic effects, incompatibilities, and concentration compatibility between raw materials; the onset of action between raw materials and efficacy; compatibility / incompatibility between efficacy and skin type; compatibility between skin type and scenario; and compatibility / incompatibility between scenario and raw materials. This ensures that all relationships are set along the efficacy transmission link, with no isolated or invalid relationships. Secondly, for each pair of adjacent entities, the confidence weight of their relationship is calculated. The weight is obtained by normalizing and fusing the correlation strength of experimental data and the correlation strength of literature evidence. The specific calculation method is as follows: First, the correlation strength of experimental data is calculated. The data sources include efficacy verification experiments provided by raw material manufacturers, human patch experiments by third-party institutions, compatibility stability experiments, and publicly available clinical efficacy test data. For the correspondence of entity pairs, the number and verification level of valid independent verification experiments are counted. Among them, human clinical trials are assigned the highest weight, followed by in vitro experiments, and in vitro simulation experiments are assigned the lowest weight. Relationships without valid experimental data are assigned a value of 0.1. Finally, the correlation strength of experimental data is normalized to the range of 0 to 1. Second, the correlation strength of literature evidence is calculated. The data sources include core journals in the field of cosmetics, Chinese core journals, and authorized invention patent literature. The frequency of occurrence and citation count of the corresponding relationship of the entity pair in high-impact literature are counted. Among them, core literature with more than 100 citations is assigned the highest value, and relationships that only appear once in non-core literature are assigned a value of 0.2. Finally, the correlation strength of literature evidence is normalized to the range of 0 to 1. Finally, a weighted fusion formula is used to calculate the final confidence weight: Relationship confidence weight = experimental data association strength × 0.6 + literature evidence association strength × 0.4. The calculated confidence weight is then uniquely bound to the corresponding entity pair and relationship type. A minimum confidence threshold of 0.3 is set, and low-confidence relationships below the threshold are eliminated to finally generate a standardized relationship set R.

[0047] By bidirectionally binding constraints with corresponding entities and relationships, a deeply coupled constraint set C is formed, ultimately resulting in a four-tuple structure of entities, relationships, attributes, and constraints. Specifically, the classification and standardization rules of constraints are first clarified, dividing constraints into two main categories: compliance hard constraints and user-personalized soft constraints. Compliance hard constraints come from the mandatory compliance requirements of current standards; user-personalized soft constraints include constraints related to raw material allergies, skin type compatibility, ingredient preferences, and special scenario adaptation. Then, complete the two-way binding of constraints with entities and relationships, and constraint decomposition and forward binding. Decompose each constraint item into a standardized rule expression that can be executed by the machine. For example, "Sodium hyaluronate is allowed to be added at a concentration of 0.05% to 2.0% in leave-on cosmetics" is decomposed into "Entity: Sodium hyaluronate, Attribute: Concentration, Constraint upper and lower limits: 0.05% to 2.0%, Applicable scenario: Leave-on products". Then, forward bind the constraint item with the corresponding sodium hyaluronate entity, concentration attribute, and leave-on scenario relationship, and add constraint tags to the corresponding entities and relationships. Second, reverse binding and constraint triggering. Set corresponding constraint triggering conditions for each entity and relationship. For example, for the constraint "Salicylic acid and sensitive skin are contraindicated", set a mandatory triggering condition for the contraindicated relationship of the entity pair "Salicylic acid-sensitive skin". When the entity pair appears in the efficacy transmission link, the contraindicated constraint is automatically triggered, the confidence weight of the relationship is forcibly set to 0, and the effective link is directly excluded. Finally, all the constraints that have completed two-way binding are integrated to form a deeply coupled constraint set C. Each basic unit forms a four-tuple structure of "entity E, relation R, attribute P, constraint C", ensuring that each four-tuple unit carries complete constraint information and that there are no entities or relations with missing constraints.

[0048] Finally, based on the quadruplet unit, with constraints as the topological boundary and relation confidence weights as the topological edge weights, a knowledge graph topology for the cosmetic formulation domain is constructed. Simultaneously, a dynamic topology update function is designed to dynamically adjust the topology and edge weights based on new data and constraint rules. The calculation method is as follows: ,in, This is the updated knowledge graph topology. For the current topology, To retain the constraint matrix, only topological nodes and edges that conform to the constraint rules are retained. To add topological increments corresponding to the new quadruples, The confidence level filtering matrix retains only newly added topological edges whose confidence weights are higher than a preset threshold. The Hadamard product operation is performed to ultimately construct the knowledge graph. Specifically, the topological structure of the knowledge graph in this embodiment... A weighted adjacency matrix is ​​used for standardized representation. The total number of entity nodes corresponding to all entity attribute binding units in the current knowledge graph is n. All entity nodes are sequentially numbered by unique IDs to form... The current topology is constructed based on the matrix dimension, which is an n-order square matrix. Any element in the matrix... The value of is determined as follows: when there is a valid relationship edge between node i and node j, the value is the confidence weight corresponding to that relationship (range 0 to 1); when there is no valid relationship edge between node i and node j, the value is 0; where i and j are the node numbers of the entity. (Constraint Preservation Matrix) It is a matrix with dimensions completely consistent with the current topology, used to verify the compliance and constraint rules of the existing topology, retaining only the topology nodes and edges that conform to the constraint rules, based on the changing constraint pairs. Assign values. Confidence screening matrix. This is a matrix with the exact same topological increment dimension as the newly added quadruple. It is used to filter out newly added topological edges with low confidence, retaining only newly added relations that meet the confidence threshold. Traversal All elements of the matrix, for each element Assign values ​​according to the following rules: If If the value is greater than or equal to the preset confidence threshold, then assign a value of 1; otherwise, assign a value of 0. Through this operation, newly added relation edges with a confidence level below a preset threshold are... The corresponding position is 0, and the result after the operation is forcibly set to 0, that is, it is removed from the topological increment; newly added relation edges that meet the confidence requirements are... The corresponding position is 1, and the original confidence weight is retained after the operation, thus realizing the confidence screening of newly added topology information. In this embodiment of the invention, the compliant existing topology matrix is ​​obtained after the Hadamard product operation. With effective incremental topology matrix It is still an n-order square matrix with completely consistent dimensions. The compliant existing topology matrix A and the effective incremental topology matrix B are added to generate the updated topology structure.

[0049] A large model for cosmetic formulation is constructed. The large model has a built-in knowledge graph embedding layer and a Transformer decoder with knowledge-constrained attention branches. After full decoding is completed, the formula generation result is output.

[0050] Furthermore, the knowledge graph embedding layer transforms the quadruple-structured domain knowledge graph into a knowledge embedding vector with the same dimension as the large model word embedding space. The TransH translation model is used to embed the quadruple-structured domain knowledge graph, mapping entities, relations, attributes, and constraints into knowledge vectors of fixed dimensions. Then, a fully connected linear projection layer projects the knowledge vectors onto a vector space with the same dimension as the large model word embedding vectors, generating standardized knowledge embedding vectors.

[0051] Furthermore, the Transformer decoder with knowledge-constrained attention branches adds knowledge-constrained attention branches to each attention module of the Transformer decoder in the large model. These knowledge-constrained attention branches run in parallel with the decoder's self-attention and cross-attention branches, integrating the knowledge embedding vectors into the token generation and reasoning process of each layer. This achieves deep alignment between the knowledge graph and the Transformer attention mechanism. Specifically, this is implemented by obtaining the input hidden state vector H of the current Transformer decoder layer and the pre-generated knowledge embedding vector matrix. ; Calculate the knowledge-constrained attention weight matrix: ,in, For the knowledge-constrained attention weight matrix, The dimension of the knowledge embedding vector; the knowledge-constrained output vector is calculated based on the knowledge-constrained attention weight matrix: and output the knowledge constraint vector. The output vectors of the self-attention branch and cross-attention branch in the same layer are concatenated, and then the dimensionality transformation and feature fusion are performed through a linear fusion layer to output the final hidden state vector of the current Transformer decoder layer.

[0052] Then, the hidden state vector dimension is mapped to match the dimension of the model's full vocabulary, and then normalized using the Softmax activation function to generate the generation probability distribution of each token within the full vocabulary. A higher probability indicates a higher semantic match between the token and the current context. Based on the probability distribution, a decoding strategy is used to select the token. The selected token is appended to the end of the input sequence and fed back into the decoder as new input. This process of hidden state calculation, probability mapping, and token selection is repeated until an end-of-sequence symbol is generated. <eos>Alternatively, the preset maximum sequence length may be reached. Finally, the generated complete token sequence is reverse-mapped into natural language text using a vocabulary, and after basic formatting, the final generated result is output.

[0053] We collect explicit and implicit preference text data from users, and perform structured parsing using an improved BERT-CRF algorithm to obtain a structured preference text dataset.

[0054] Furthermore, in step S3, the explicit preference text data includes the user's directly input target efficacy, raw material preferences, and post-use scenario needs data; the implicit preference text data includes the user's historical browsing of cosmetic formula-related content, past evaluation feedback of cosmetics used, and formula selection record data.

[0055] Furthermore, step S3, which uses an improved BERT-CRF algorithm for structured parsing to obtain a structured preference text dataset, specifically involves: cleaning, segmenting, and normalizing the input full text data; converting the text into a fixed-length token sequence, denoted as... Where n is the preset fixed length of the token sequence, It is the i-th token in the sequence;

[0056] Sub-word semantic embeddings, word-level semantic embeddings, and phrase-level semantic embeddings are generated for the token sequence, respectively. An adaptive gating mechanism is used to dynamically fuse these multi-granularity embeddings, generating the final input embedding matrix. Specifically, the calculation process involves obtaining the sub-word embeddings corresponding to the i-th token. Word-level embedding Phrase-level embedding All three dimensions are consistent; calculate the adaptive fusion weights for multi-granularity embedding: ,in, This is the weight matrix. For bias terms, These are the fusion weight coefficients for the corresponding three granularity embeddings. include ; Calculate the final fused embedding vector of the i-th token. : The fused embedding vectors of all tokens are combined to form the input embedding matrix E, which is then fed into the improved BERT coding layer.

[0057] An improved BERT encoding layer is constructed to complete the global semantic encoding of the input text and generate a multi-dimensional fused semantic feature matrix. The improved BERT encoding layer consists of stacked encoding blocks with L identical layers, each block undergoing decoupled dual-path multi-head attention computation. This decoupled dual-path multi-head attention computation involves setting parallel content semantic attention branches and position-dependent attention branches, independently modeling the semantic association and positional dependency of the input features respectively. After computation, dynamic fusion is performed. Specifically, for the first... A layer coding layer whose input is the hidden state output from the previous layer. The first-level input is the embedding matrix E generated in the previous step, which generates query, key, and value matrices for two branches, including a content semantic attention branch: , , Location-dependent attention branch: , , ;in, These are the linear mapping weight matrices for the content semantic branches. These are the linear mapping weight matrices for the position-dependent branches; the multi-head attention output and content semantic attention output for the two branches are calculated separately, with attention weights calculated solely based on semantic similarity to remove interference from positional information: The single-head attention calculation is as follows: Where h is the number of attention heads, The dimension of the single-headed key matrix. The content branch is fused with a weight matrix; the position-dependent attention output calculates attention weights based solely on relative positional relationships, removing semantic content interference. The single-head attention calculation is as follows: ,in, This is a relative position encoding matrix. The positional branch weight matrix is ​​used; the dynamic weight matrix of the two branch outputs is calculated to complete the attention output fusion: , ,in It is the Sigmoid activation function. This is the weight matrix. For bias terms, For the adaptive fusion weights of content semantic branches, This is the final output of dual-path attention.

[0058] For the first Raw input of layer coded block The result of dual-path attention calculation As input, residual normalization and gated feedforward transformation are performed. First, identity residual fusion and layer normalization calibration are completed for the two inputs. Then, feature nonlinear transformation and key information filtering are completed through a gated feedforward network. Finally, residual fusion and layer normalization are performed again to output the first... The final hidden state matrix of the layer coded block Specifically, for the first Raw input of layer coded block The result of dual-path attention calculation As input, residual connections are performed, and then feature distribution standardization and calibration are completed through layer normalization to eliminate internal covariate bias. The calculation method is as follows: ,in, For layer normalization operation, These are the intermediate features after the first normalization. Then, using... As input, a gated feedforward structure is constructed through parallel dual-path linear mapping to complete the high-dimensional nonlinear transformation of features and adaptive selection of key semantic information, and then mapped back to the original feature dimension. The calculation formula is as follows: ,in, The weight matrix is ​​a parallel upsampling linear mapping. For the corresponding bias term, GELU is the Gaussian error linear activation function. For Hadamard product operations, These are the downsampling linear mapping weight matrix and the corresponding bias term, respectively. The feature matrix is ​​the output of the feedforward transform; the original input to the gated feedforward neural network. With output Perform residual connections, and then complete the final feature distribution calibration through layer normalization to obtain the first... The final output hidden state matrix of the layer-coded block is calculated as follows: .

[0059] After completing the stacking computation of L-layer encoding blocks, the set of hidden state matrices for all layers is obtained. Layer normalization pre-calibration is performed on the features of all layers. Then, adaptive fusion weights for each layer are learned through a hierarchical attention mechanism. After completing multi-layer weighted fusion, residual optimization and final calibration are performed in combination with deep features to output a global semantic feature matrix adapted to structured parsing tasks. Specifically, this is achieved by performing layer normalization pre-calibration on the hidden state matrix of each layer to eliminate the feature distribution differences between different coding layers, thus obtaining the... Hidden state matrix after layer calibration: The adaptive fusion weights for each layer are learned through a hierarchical attention mechanism. Global average pooling is performed on the calibrated hidden state matrix of each layer to obtain the global feature representation of the corresponding layer. Then, normalized fusion weights for each layer are generated through a fully connected mapping network and a softmax activation function. The calculation method is as follows: ,in, For the first The global feature vector of the layer, For the first The feature vector corresponding to the i-th token in the layer, where n is a fixed length of the token sequence, is obtained through... Calculation yields the first The adaptive fusion weights corresponding to the layers, The MLP is a two-layer fully connected mapping network used to map layer global features to weight scores. Finally, multi-layer weighted fusion is performed based on adaptive fusion weights, and then residual optimization and final feature calibration are used to generate a global semantic feature matrix adapted to the structured parsing task. The calculation method is as follows: , ,in, The feature matrix after hierarchical weighted fusion. The hidden state matrix after calibration of the last coded block. This is the final output global semantic feature matrix, used for label sequence prediction in subsequent decoding layers.

[0060] The global semantic feature matrix is ​​input into the CRF decoding layer, which decodes and outputs the optimal label sequence, completing information extraction and structured mapping to generate a standardized structured preference text dataset. Specifically, the global semantic feature matrix output from the improved BERT encoding layer is input into a fully connected linear layer, mapping the feature vector corresponding to each token to the dimensions of a predefined label system, generating emission score matrices for each token across various labels, thus completing the standardized transformation from semantic features to label scores. The CRF layer, based on a pre-trained label transition probability matrix, solidifies the legal transition rules between labels, avoiding label logic errors caused by independent prediction of single tokens. Then, using the Viterbi algorithm, the global joint probability of all legal label sequences is calculated by combining emission scores and transition scores, selecting the optimal label sequence with the highest global probability. The optimal label sequence is mapped one-to-one with the original token sequence to complete entity and attribute information extraction, aligning with the standard ontology of the knowledge graph to complete normalization mapping, and finally generating a standardized structured preference text dataset.

[0061] Finally, the structured preference text dataset is input into a large model in the field of cosmetic formulation to generate formulation schemes that match the user's ingredient preferences.

[0062] In summary, the logical chain of this invention is a complete closed-loop logical chain of knowledge foundation construction, domain-wide model adaptation, user requirement analysis, and personalized formula generation. First, a structured cosmetic formula domain knowledge graph consisting of entities, relationships, attributes, and constraints is constructed to obtain a professional domain knowledge foundation. Then, a large-scale formula domain model deeply aligned with the knowledge graph and the Transformer attention mechanism is built to achieve deep integration of domain knowledge and generative reasoning. Subsequently, an improved BERT-CRF algorithm is used to parse user explicit and implicit preference text, generating a standardized structured preference dataset. Finally, this dataset is input into the large-scale model to generate cosmetic formula solutions that match user ingredient preferences and meet compliance standards.

[0063] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments for application in other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.< / eos>

Claims

1. A method for intelligent recommendation of cosmetic formulations based on ingredient preferences, characterized in that, Includes the following steps: S1. Construct a knowledge graph for the cosmetic formulation field with a four-tuple structure; S2. Construct a large model for cosmetic formulation, which includes a built-in knowledge graph embedding layer and a Transformer decoder with knowledge-constrained attention branches. After full decoding, the model outputs the formulation generation result. S3. Collect users' explicit and implicit preference text data, and perform structured parsing using an improved BERT-CRF algorithm to obtain a structured preference text dataset; S4. Input the structured preference text dataset into the large model of cosmetic formulation to generate a formulation scheme that matches the user's ingredient preferences.

2. The intelligent recommendation method for cosmetic formulations based on ingredient preferences according to claim 1, characterized in that, In step S1, the four-tuple is a structure of entities, relations, attributes, and constraints. Entities include cosmetic raw materials, efficacy, skin type, and usage scenarios. Relationships include synergistic, compatibility, and contraindications among raw materials. Attributes include the physicochemical parameters and concentration range of raw materials. Constraints include user allergies and restrictions on the use of raw materials.

3. The intelligent recommendation method for cosmetic formulations based on ingredient preferences according to claim 2, characterized in that, The specific implementation of constructing a four-tuple structured knowledge graph for the cosmetic formulation domain is as follows: S11. Construct a standardized ontology library specifically for the cosmetics field, and perform word segmentation, noise reduction, and entity linking on unstructured and semi-structured text data from various data sources to generate a standardized corpus. S12. Taking the complete efficacy transmission link of cosmetic formula raw material entity, efficacy entity, skin type entity and scene entity as the core framework, the entity set E of each node in the link and the attribute set P deeply bound to the entity are extracted from the standardized corpus to generate entity attribute binding unit. S13. Using entity attribute binding units as nodes and efficacy transmission links as paths, calculate the relationship confidence weight between adjacent entity pairs in the link. The relationship confidence weight is obtained by normalizing and fusing the correlation strength of experimental data and literature evidence. Bind the calculated relationship confidence weight with the corresponding entity pair and relationship type to generate a relationship set R. S14. Bind the constraints to the corresponding entities and relations in two directions to form a deeply coupled constraint set C, and finally obtain a quadruple structure of entities, relations, attributes and constraints. S15. Based on quadruples, with constraints as topological boundaries and relation confidence weights as topological edge weights, construct a knowledge graph topology for the cosmetic formulation domain. Simultaneously, design a dynamic topology update function to dynamically adjust the topology and edge weights based on new data and constraint rules. The calculation method is as follows: ,in, This is the updated knowledge graph topology. For the current topology, To retain the constraint matrix, only topological nodes and edges that conform to the constraint rules are retained. To add topological increments corresponding to the new quadruples, The confidence level filtering matrix retains only newly added topological edges whose confidence weights are higher than a preset threshold. The Hadamard product operation is performed to ultimately complete the construction of the knowledge graph.

4. The intelligent recommendation method for cosmetic formulations based on ingredient preferences according to claim 1, characterized in that, In step S2, a large model for cosmetic formulation is constructed, and the knowledge graph embedding layer is: The quadruple-structured domain knowledge graph is transformed into a knowledge embedding vector with the same dimension as the word embedding space of the large model. The TransH translation model is used to embed the quadruple-structured domain knowledge graph, mapping entities, relations, attributes and constraints into knowledge vectors of fixed dimensions. Then, the knowledge vectors are projected to a vector space with the same dimension as the word embedding vector of the large model through a fully connected linear projection layer, generating a standardized knowledge embedding vector.

5. The intelligent recommendation method for cosmetic formulations based on ingredient preferences according to claim 1, characterized in that, In step S2, a large model for cosmetic formulation is constructed. The Transformer decoder with knowledge-constrained attention branches adds knowledge-constrained attention branches to each attention module of the Transformer decoder in the large model. These knowledge-constrained attention branches run in parallel with the decoder's self-attention and cross-attention branches, integrating knowledge embedding vectors into the token generation and reasoning process of each layer. This achieves deep alignment between the knowledge graph and the Transformer attention mechanism. Specifically, the implementation is as follows: S221. Obtain the input hidden state vector H of the current Transformer decoder layer, and the pre-generated knowledge embedding vector matrix. ; S222, Calculate the knowledge-constrained attention weight matrix: ,in, For the knowledge-constrained attention weight matrix, The dimension of the knowledge embedding vector; S223. Calculate the knowledge-constrained output vector based on the knowledge-constrained attention weight matrix: and output the knowledge constraint vector. The output vectors of the self-attention branch and cross-attention branch in the same layer are concatenated, and then the dimensionality transformation and feature fusion are performed through a linear fusion layer to output the final hidden state vector of the current Transformer decoder layer.

6. The intelligent recommendation method for cosmetic formulations based on ingredient preferences according to claim 1, characterized in that, In step S3, explicit preference text data includes the user's directly input target efficacy, raw material preferences, and post-use scenario needs data; implicit preference text data includes the user's historical browsing of cosmetic formula-related content, past evaluation feedback of cosmetics used, and formula selection record data.

7. The intelligent recommendation method for cosmetic formulations based on ingredient preferences according to claim 1, characterized in that, The specific implementation of step S3, which uses an improved BERT-CRF algorithm for structured parsing to obtain a structured preference text dataset, is as follows: S31. Perform preprocessing on the input full text data, including cleaning, word segmentation, and length normalization, to convert the text into a fixed-length token sequence, denoted as... Where n is the preset fixed length of the token sequence, It is the i-th token in the sequence; S32. Generate word-level semantic embeddings, phrase-level semantic embeddings, and sub-word-level semantic embeddings for the token sequence, respectively. Use an adaptive gating mechanism to achieve dynamic fusion of multi-granularity embeddings and generate the final input embedding matrix. S33. Construct an improved BERT encoding layer to complete the global semantic encoding of the input text and generate a multi-dimensional fused semantic feature matrix; The improved BERT coding layer is composed of stacked coding blocks with the same L-layer structure, and each coding block performs decoupled dual-path multi-head attention computation. The decoupled dual-path multi-head attention computation involves setting up parallel content semantic attention branches and position-dependent attention branches, which independently model the semantic associations and positional dependencies of the input features, respectively. After computation, these branches are dynamically fused to obtain the dual-path attention output. ; S34, regarding the first Raw input of layer coded block The result of dual-path attention calculation As input, residual normalization and gated feedforward transformation are performed. First, identity residual fusion and layer normalization calibration are completed for the two inputs. Then, feature nonlinear transformation and key information filtering are completed through a gated feedforward network. Finally, residual fusion and layer normalization are performed again to output the first... The final hidden state matrix of the layer coded block ; S35. After completing the stacking calculation of the L-layer coding blocks, the set of hidden state matrices of all layers is obtained. Layer normalization pre-calibration is performed on the features of all layers. Then, the adaptive fusion weights of each layer are learned through a hierarchical attention mechanism. After completing the multi-layer weighted fusion, residual optimization and final calibration are performed in combination with deep features to output a global semantic feature matrix adapted to the structured parsing task. ; S36. Input the global semantic feature matrix into the CRF decoding layer, decode and output the optimal label sequence, complete information extraction and structured mapping, and generate a standardized structured preference text dataset.

8. The intelligent recommendation method for cosmetic formulations based on ingredient preferences according to claim 7, characterized in that, The specific implementation of step S33 is as follows: S331, regarding the first A layer coding layer whose input is the hidden state output from the previous layer. The first-level input is the embedding matrix E generated in the previous step, which generates query, key, and value matrices for two branches, including a content semantic attention branch: , , Location-dependent attention branch: , , ;in, These are the linear mapping weight matrices for the content semantic branches. These are the linear mapping weight matrices for the position-dependent branches; S332. Calculate the multi-head attention output and content semantic attention output for the two branches respectively, and calculate the attention weights based solely on semantic similarity, removing the interference of location information: The single-head attention calculation is as follows: Where h is the number of attention heads, The dimension of the single-headed key matrix. The content branch is fused with a weight matrix; the position-dependent attention output calculates attention weights based solely on relative positional relationships, removing semantic content interference. The single-head attention calculation is as follows: ,in, This is a relative position encoding matrix. This is the position branch weight matrix; S333. Calculate the dynamic weight matrix of the two branch outputs to complete the attention output fusion: , ,in It is the Sigmoid activation function. This is the weight matrix. For bias terms, For the adaptive fusion weights of content semantic branches, This is the final output of dual-path attention.