A manufacturing microservice discovery and dynamic screening method based on LDA and rule chain
By combining LDA and rule chaining, the problems of insufficient semantic understanding and rule constraints in the manufacturing microservice discovery method are solved, and accurate discovery and dynamic screening of manufacturing microservices are achieved, which improves efficiency and accuracy and meets the personalized and dynamic needs of users.
Patent Information
- Application Number
- CN202410680815.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2044-05-29
AI Technical Summary
Existing manufacturing microservice discovery methods lack semantic understanding and rule constraints, resulting in low discovery precision and accuracy, unable to meet user personalized and dynamic needs, and lack dynamic screening and optimization capabilities, resulting in low efficiency.
Abstract: In order to solve the problem of microservice discovery and dynamic screening, a method based on Latent Dirichlet Allocation (LDA) and rule chain is used. By building a domain service clustering model and using Gibbs sampling method for training and solving, the feature word column vectors of microservices and rules are generated, and the similarity matching rules are calculated. The message event triggering mechanism of rule chain is combined to realize the discovery and dynamic screening of microservices. The results show that the proposed method can realize the discovery and dynamic screening of microservices by combining the Latent Dirichlet Allocation (LDA) and rule chain. The ...
It achieves accurate discovery and dynamic screening of manufacturing microservices, improves the efficiency and accuracy of discovery, meets users' personalized and dynamic needs, and optimizes the efficiency of microservice combination and deployment.
Smart Images

Figure CN118984332B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of Internet big data and microservices, and in particular to a manufacturing microservice discovery and dynamic screening method based on LDA and rule chain. Background Art
[0002] In the context of the Industrial Internet, microservices architecture, as a lightweight, modular software architecture style, is increasingly favored by manufacturing companies. Microservices architecture breaks down traditional monolithic applications into multiple small, autonomous service units, each built and deployed around a specific business function. This approach achieves high system cohesion, loose coupling, and rapid iteration. However, with the increasing number of microservices and the increasing degree of decoupling, effectively discovering and dynamically selecting microservices that meet actual needs has become a new challenge for manufacturing companies.
[0003] Traditional manufacturing microservice discovery methods mostly rely on manual search and recommendation, which are inefficient and difficult to adapt to large-scale and complex manufacturing environments. In order to solve this problem, the prior art has proposed a manufacturing microservice discovery method based on manufacturing service technology, which constructs and manages a microservice library for manufacturing services and uses automation technology to achieve the discovery and selection of microservices. For example, the Chinese patent with publication number CN114637266A discloses "A control method and device based on microservices", which includes: obtaining a set of operation commands for a manufacturing control system; identifying hardware tags in the operation commands, and determining at least one hardware operation library and a corresponding target controller corresponding to the operation command based on the hardware tags; filtering out target control instructions corresponding to the hardware operation library and the operation command from the control library; and sending the target control instructions to the target controller so that the target controller executes the target control instructions.
[0004] However, existing manufacturing microservice discovery methods based on manufacturing service technologies have several issues, primarily manifested in the following aspects: First, most existing methods lack the ability to understand and describe the semantics of manufacturing services, resulting in low precision and accuracy in microservice discovery. Second, existing methods often ignore the rules and relationships between manufacturing microservices, failing to meet user needs for personalized and dynamic operations. Furthermore, existing methods lack the ability to dynamically screen and optimize manufacturing microservices, making it impossible to achieve targeted microservice combination and optimization, resulting in low efficiency in microservice combination and optimization. Summary of the Invention
[0005] In view of the above-mentioned deficiencies in the existing technology, the technical problem to be solved by the present invention is: how to provide a manufacturing microservice discovery and dynamic screening method based on LDA and rule chain. By combining LDA and rule chain, the semantic information and rule constraints of manufacturing microservices can be fully utilized to achieve accurate discovery and dynamic screening of manufacturing microservices, thereby improving the efficiency and accuracy of manufacturing microservice discovery, and further providing manufacturing enterprises with an efficient, accurate and personalized manufacturing microservice discovery and selection solution, thereby promoting the automation and intelligent development of manufacturing services.
[0006] In order to solve the above technical problems, the present invention adopts the following technical solutions:
[0007] The manufacturing microservice discovery and dynamic screening method based on LDA and rule chain includes:
[0008] S1: Build a domain service clustering model using the LDA algorithm and train and solve the domain service clustering model;
[0009] S2: Obtain a microservice set containing several microservice description documents and input them into the domain service clustering model. Output the topic-feature word probability distribution of all microservices, and then construct the feature word column vector of the microservice topic.
[0010] S3: Obtain a rule set containing several rule description documents and input it into the domain service clustering model. Output the topic-feature word probability distribution of all rules, and then construct the feature word column vector of the rule topic.
[0011] S4: By calculating the similarity between the feature word column vectors of the microservice topic and the rule topic, we match the rules with similar semantics to the microservice, and then filter out the rules that meet the conditions and put them into the candidate rule set;
[0012] S5: Generate a rule chain based on the alternative rule set and the set rule constraints, and realize the discovery and dynamic screening of microservices through the message event triggering mechanism of the rule chain.
[0013] Preferably, in step S1, the input of the domain service clustering model is the description document, and the output is the document-topic probability distribution and the topic-feature word probability distribution of the description document.
[0014] Preferably, in step S1, the domain service clustering model generates a reconstructed document set consisting of feature words based on the input description document set, wherein the joint probability distribution P of the reconstructed document being consistent with the description document is expressed as:
[0015]
[0016] Where: P is the joint probability distribution, which represents the probability that the reconstructed document generated by the domain service clustering model is consistent with the description document; Indicates that the topic distribution parameter θ is calculated for each description document J J The probability of , M is the number of documents; Indicates that the characteristic word distribution parameters are calculated for each topic I The probability of; K is the number of topics; Indicates that the topic Z is calculated for each position t of each description document j j,t probability; Indicates that the feature word W is calculated for each position t of each description document j j,t probability.
[0017] Preferably, in step S1, the domain service clustering model is trained and solved using the Gibbs sampling method to obtain document-topic probability distribution and topic-feature word probability distribution. The specific steps are as follows:
[0018] S101: Randomly assign an initial topic to each word in the description document;
[0019] S102: For each word in each description document, perform the following steps in sequence:
[0020] S1021: Randomly select a word w that describes document d and record its current topic as z;
[0021] S1022: Remove the association count between word w and topic z from description document d;
[0022] S1023: Considering the topic distribution of other words in the description document d and the topic distribution of word w in other description documents, calculate the conditional probability distribution of the possible topic distribution of word w;
[0023] S1024: Reassign a topic k to word w according to the conditional probability distribution of topic distribution;
[0024] S1025: Update the association count between word w and topic k in description document d;
[0025] S103: Repeat step S102 to implement iteration until the domain service clustering model converges or the number of iterations is reached;
[0026] S104: After the domain service clustering model is trained and solved using the Gibbs sampling method, each word is assigned a topic: the number of occurrences of each topic in each document is counted to obtain a document-topic probability distribution; the number of occurrences of each word under each topic is counted to obtain a topic-feature word probability distribution.
[0027] Preferably, in step S2, the feature word proportion corresponding to each microservice topic is calculated based on the topic-feature word probability distribution of all microservices to form the feature word column vector of the microservice topic, where the feature word column vector SV of the i-th microservice topic is i =(SW i1 ,SW i2 ,…,SW in ) T , SW in Indicates the proportion of the nth feature word in the i-th microservice topic;
[0028] In step S3, based on the topic-feature word probability distribution of all rules, the feature word ratio corresponding to each rule topic is calculated to form the feature word column vector of the rule topic, where the feature word column vector RV of the jth rule topic is j =(RW j1 ,RW j2 ,…,RW jm ), RW jm Indicates the proportion of the mth feature word in the jth microservice topic.
[0029] Preferably, in step S1, the domain service clustering model and a given description document set are used as input to calculate the topic perplexity, and the topic perplexity is used as the number of topics in the domain service clustering model;
[0030] The calculation formula of topic perplexity is as follows:
[0031]
[0032] Where: D represents the number of documents in a given description document set; N d represents the number of words describing the dth document; p(DS d ) represents the predicted probability of the domain service clustering model for the dth description document.
[0033] Preferably, in step S4, the candidate rule set is generated by the following steps:
[0034] S401: Determine the feature word column vector SV of the microservice topic i And the feature word column vector RV of the rule topic j ;
[0035] S402: SV i With RV j All the feature words in are merged into one word set and SV is calculated. i With RV j The word frequency vector SV i ′ and RV j ';
[0036] S403: RVj ' is synthesized into a regular feature word probability distribution matrix SM;
[0037] The formula is:
[0038]
[0039] Where: a represents the total number of rules, satisfying 0≤j≤a;
[0040] S404: Column vector SV i ′ performs a dot product operation with each row of the matrix SM to obtain the dot product result Dot products ;
[0041] The formula is:
[0042]
[0043] S405: Calculate vector SV i The Euclidean norm of ′
[0044] S406: Calculate the Euclidean norm of each row of the matrix SM
[0045] S407: Use dot product result Dot products Calculate the cosine similarity with the Euclidean norm and get Cosine similarity[j] vector;
[0046] The formula is:
[0047]
[0048] S408: Cosine similarity[j] The rules corresponding to the values reaching the similarity threshold STH are added to the candidate rule set.
[0049] Preferably, in step S5, the rule constraint includes an inter-layer relationship constraint, wherein the inter-layer relationship constraint considers the number of layers of the rule priority level;
[0050] When generating a rule chain, the rules in the alternative rule set are linked in order of priority: general level, subject level, and user-defined level.
[0051] Preferably, in step S5, the rule constraint includes an intra-layer relationship constraint, wherein the intra-layer relationship constraint considers the pre-rule set P of the rule R , conflict rule set C R With the post-rule set S R ;
[0052] When generating a rule chain, the intra-layer rule chain RC should satisfy the relationship described by the following formula:
[0053]
[0054] Where: (RN q ∈RN q+1 .P R )∪(RN q+1 ∈RN q .S R ) indicates that the previous rule is in the preceding rule set of the subsequent rule, or the subsequent rule is in the post-rule set of the previous rule; Indicates that neither rule is in the other's conflicting rule set.
[0055] Preferably, in step S5, after the rule chain is generated, the symbols and values of each rule node in the rule chain are adjusted according to its own needs to complete the dynamic screening of microservices.
[0056] Compared with the existing technology, the manufacturing microservice discovery and dynamic screening method based on LDA and rule chain in the present invention has the following beneficial effects:
[0057] This paper addresses the current challenges of filtering services for some manufacturing enterprises, particularly due to the large scale and diverse scope of services within microservices architectures. By designing a method for discovering and dynamically filtering manufacturing microservices based on Latent Dirichlet Allocation (LDA) and rule chains, this paper introduces an LDA model to extract topic information from a large number of microservice text descriptions. This model is then trained and solved using Gibbs sampling to achieve semantic understanding, abstraction, and description of microservices. This approach then transforms microservices into vector representations in a semantic topic space, enabling the automatic discovery of microservices in manufacturing-related domains. On the other hand, in order to narrow the screening scope of manufacturing microservices and improve the efficiency of subsequent microservice deployment, the present invention designs a rule set and rule chain generation method based on the above model. First, the feature word column vectors of microservices and rule nodes are obtained through the above model, and similarity matching is performed on them to generate a backup rule set that can constrain manufacturing microservices. Then, a rule chain is generated in combination with the set rule constraints to realize the discovery and dynamic screening of microservices through the message event triggering mechanism of the rule chain. Manufacturing enterprises can flexibly change the microservice screening strategy by real-time configuration of rule nodes according to production needs, which not only meets the user's personalized and dynamic needs, but also can effectively dynamically screen and optimize manufacturing microservices, and then discover manufacturing microservices that meet the needs of the enterprise, thereby improving the efficiency of subsequent microservice optimization and deployment.
[0058] In summary, by combining LDA and rule chaining, the present invention can fully utilize the semantic information and rule constraints of manufacturing microservices, realize the accurate discovery and dynamic screening of manufacturing microservices, and improve the efficiency and accuracy of manufacturing microservice discovery. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to make the purpose, technical solutions and advantages of the invention more clear, the present invention will be further described in detail below with reference to the accompanying drawings, in which:
[0060] Figure 1 It is the overall framework of the manufacturing microservice discovery and dynamic screening method based on LDA-rule chain;
[0061] Figure 2 It is the relationship structure of various parameters in the document generation process;
[0062] Figure 3 It is the process of document generation;
[0063] Figure 4 is the perplexity curve;
[0064] Figure 5 is the probability distribution result of topic-feature word (when the number of topics input is 7, 8, 9, and 10 respectively);
[0065] Figure 6 This is the distribution of feature words when the number of topics input is 8;
[0066] Figure 7 The similarity matrix heat map of the 8 topics and the first 20 rule nodes;
[0067] Figure 8 Display of heatmap matching results that meet the similarity threshold;
[0068] Figure 9 Generate examples for rule chains;
[0069] Figure 10 The final screening results;
[0070] Figure 11 The efficiency of the service combination is compared with whether the method of the present invention is used for preprocessing. DETAILED DESCRIPTION
[0071] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention claimed for protection, but only represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0072] It should be noted that similar reference numerals and letters denote similar items in the following figures. Therefore, once an item is defined in one figure, it does not require further definition or explanation in subsequent figures. In the description of the present invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer" indicate positions or relationships based on the positions or relationships shown in the figures, or the positions or relationships in which the inventive product is typically placed when in use. These terms are intended solely to facilitate the description of the present invention and simplify the description. They do not indicate or imply that the devices or components referred to must have a specific orientation, be constructed, or operate in a specific orientation, and are therefore not to be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third," etc., are used solely to distinguish descriptions and are not to be construed as indicating or implying relative importance. Furthermore, terms such as "horizontal" and "vertical" do not imply that a component is absolutely horizontal or overhanging, but rather may be slightly tilted. For example, "horizontal" simply means that its direction is more horizontal than "vertical," and does not mean that the structure must be completely horizontal, but rather may be slightly tilted. In the description of the present invention, it should also be noted that, unless otherwise expressly specified or limited, the terms "disposed," "installed," "connected," and "connected" should be understood in a broad sense. For example, they may refer to fixed connections, detachable connections, or integral connections; they may refer to mechanical connections or electrical connections; they may refer to direct connections or indirect connections through an intermediate medium; and they may refer to internal communication between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on the specific circumstances.
[0073] The following is a further detailed description through specific implementation methods:
[0074] Example:
[0075] This embodiment discloses a manufacturing microservice discovery and dynamic screening method based on LDA and rule chaining.
[0076] like Figure 1 As shown in the figure, the manufacturing microservice discovery and dynamic screening method based on LDA and rule chain includes:
[0077] S1: Build a domain service clustering model (hereinafter referred to as the LDA model) using the Latent Dirichlet Allocation (LDA) algorithm and train and solve the domain service clustering model.
[0078] S2: Obtain a microservice set containing several microservice description documents and input them into the domain service clustering model. Output the topic-feature word probability distribution of all microservices, and then construct the feature word column vector of the microservice topic.
[0079] S3: Obtain a rule set containing several rule description documents and input it into the domain service clustering model. Output the topic-feature word probability distribution of all rules, and then construct the feature word column vector of the rule topic.
[0080] S4: By calculating the similarity between the feature word column vectors of the microservice topic and the rule topic, we match the rules with similar semantics to the microservice, and then (by setting a reasonable similarity threshold) filter out the rules that meet the (threshold) conditions and put them into the candidate rule set;
[0081] S5: Generate a rule chain based on the alternative rule set and the set rule constraints, and realize the discovery and dynamic screening of microservices through the message event triggering mechanism of the rule chain.
[0082] In this embodiment, after the rule chain is generated, enterprises or users can adjust the symbols and values of each rule node in the rule chain according to their needs to achieve dynamic screening of microservices. Users can configure the properties of each rule node in the rule chain based on actual production needs, such as the collection coverage of a device detecting a microservice (e.g., collection coverage > 0.7). Message events in the rule chain include microservice updates and user demand updates.
[0083] This paper addresses the current challenges of filtering services for some manufacturing enterprises, particularly due to the large scale and diverse scope of services within microservices architectures. By designing a method for discovering and dynamically filtering manufacturing microservices based on Latent Dirichlet Allocation (LDA) and rule chains, this paper introduces an LDA model to extract topic information from a large number of microservice text descriptions. This model is then trained and solved using Gibbs sampling to achieve semantic understanding, abstraction, and description of microservices. This approach then transforms microservices into vector representations in a semantic topic space, enabling the automatic discovery of microservices in manufacturing-related domains. On the other hand, in order to narrow the screening scope of manufacturing microservices and improve the efficiency of subsequent microservice deployment, the present invention designs a rule set and rule chain generation method based on the above model. First, the feature word column vectors of microservices and rule nodes are obtained through the above model, and similarity matching is performed on them to generate a backup rule set that can constrain manufacturing microservices. Then, a rule chain is generated in combination with the set rule constraints to realize the discovery and dynamic screening of microservices through the message event triggering mechanism of the rule chain. Manufacturing enterprises can flexibly change the microservice screening strategy by real-time configuration of rule nodes according to production needs, which not only meets the user's personalized and dynamic needs, but also can effectively dynamically screen and optimize manufacturing microservices, and then discover manufacturing microservices that meet the needs of the enterprise, thereby improving the efficiency of subsequent microservice optimization and deployment.
[0084] In summary, by combining LDA with rule chaining, this paper can fully utilize the semantic information and rule constraints of manufacturing microservices to achieve accurate discovery and dynamic screening of manufacturing microservices, thereby improving the efficiency and accuracy of manufacturing microservice discovery. This implementation demonstrates the feasibility and effectiveness of the proposed method, providing new ideas and methods for intelligent service discovery and dynamic screening in the field of manufacturing enterprise microservices.
[0085] In the specific implementation process, the input of the domain service clustering model is the description document, and the output is the document-topic probability distribution and topic-feature word probability distribution of the description document.
[0086] In the specific implementation process, the probability density function of the domain service clustering model is expressed as:
[0087]
[0088]
[0089] Where: x1, x2…, x k Represents the probability value of k categories; α1, α2…, α k Represents the parameters of the distribution, and satisfies α i >0; the function B(α) is the multivariate beta function; Γ(·) represents the gamma function;
[0090] The parameter α of the LDA model can be seen as a concentration parameter that affects the shape of the distribution in each dimension. When the value of α is larger, the distribution tends to be more concentrated in each category, while when the value of α is smaller, the distribution tends to be more uniform.
[0091] For ease of description, we define a four-tuple to represent a probabilistic Domain Service Clustering Model (DSCM). The Domain Service Clustering Model is defined as DSCM = (DS, DT, V, PO), where DS = {S} is the domain microservice set, representing the set of microservices belonging to a certain domain; DT = {T} is the set of topics encompassed by all microservices within a specific domain; V = {t} represents the set of terminology encompassed by all microservices within a specific domain; and PO = {Policy} represents the probability that a microservice document contains different topics, thereby determining to which topic cluster the microservice belongs.
[0092] The domain service clustering model generates a set of reconstructed documents consisting of feature words based on the input description document set. The joint probability distribution P of the reconstructed documents generated by the domain service clustering model and the description documents is expressed as:
[0093]
[0094] Where P is the joint probability distribution, which represents the probability that the reconstructed document generated by the domain service clustering model (stop words are filtered out using the TF-IDF method; in fact, the document generated by LDA is just a bag-of-words model composed of many feature words, without specific sentences) is consistent with the description document. Indicates that the topic distribution parameter θ is calculated for each description document J J The probability of , M is the number of documents; Indicates that the characteristic word distribution parameters are calculated for each topic I The probability of; K is the number of topics; Indicates that the topic Z is calculated for each position t of each description document j j,t probability; Indicates that the feature word W is calculated for each position t of each description document j j,t probability;
[0095] The above formula describes the process of domain service clustering model to generate reconstructed documents. Each word W in the reconstructed document j,t All of them are done by first starting with the topic distribution parameter θ j Sampling subject Z j,t , and then from the vocabulary distribution of the corresponding topic Sampling obtained.
[0096] During implementation, the LDA model generates several documents consisting of a set of feature words. However, computers often cannot understand the meaning of feature words and can only focus on the occurrence of a particular feature word in a document. To address this issue, the present invention uses Gibbs sampling to train and solve the domain service clustering model. Gibbs sampling is a sampling method used in Markov Chain Monte Carlo (MCMC) and can be used to sample from multivariate probability distributions.
[0097] The specific steps are as follows:
[0098] S101: Randomly assign an initial topic to each word in the description document;
[0099] S102: For each word in each description document, perform the following steps in sequence:
[0100] S1021: Randomly select a word w that describes document d and record its current topic as z;
[0101] S1022: Remove the association count between word w and topic z from description document d;
[0102] S1023: Considering the topic distribution of other words in the description document d and the topic distribution of word w in other description documents, calculate the conditional probability distribution of the possible topic distribution of word w;
[0103] The goal of Gibbs sampling is to make it close to the distribution P(Z|W,α,β). Since W,α,β are known, Z mn Indicates the topic corresponding to the nth word of the mth description document, Z -mn Indicates Z without Z mn The topic distribution after that is as follows;
[0104]
[0105] S1024: Reassign a topic k to word w according to the conditional probability distribution of topic distribution;
[0106] S1025: Update the association count between word w and topic k in description document d;
[0107] S103: Repeat step S102 to implement iteration until the domain service clustering model converges or the number of iterations is reached;
[0108] S104: After the domain service clustering model is trained and solved using the Gibbs sampling method, each word is assigned a topic: the number of occurrences of each topic in each document is counted to obtain a document-topic probability distribution; the number of occurrences of each word under each topic is counted to obtain a topic-feature word probability distribution.
[0109] The Gibbs sampling adopted in the present invention is a local update method. For each variable in the document, only its neighboring variables need to be considered instead of the entire data set. This local property makes Gibbs sampling relatively efficient in LDA model training.
[0110] During the specific implementation process, the generation of feature word column vectors is as follows:
[0111] Based on the topic-feature word probability distribution of all microservices, the feature word ratio corresponding to each microservice topic is calculated to form the feature word column vector of the microservice topic, where the feature word column vector SV of the i-th microservice topic is i =(SW i1 ,SW i2 ,…,SW in ) T , SW in Indicates the proportion of the nth feature word in the i-th microservice topic.
[0112] Based on the topic-feature word probability distribution of all rules, the feature word ratio corresponding to each rule topic is calculated to form the feature word column vector of the rule topic, where the feature word column vector RV of the jth rule topic is j =(RW j1 ,RW j2 ,…,RW jm ), RW jm Indicates the proportion of the mth feature word in the jth microservice topic.
[0113] In the specific implementation process, for topic models, once the selected algorithm is determined, the hyperparameter that needs to be manually determined is usually the number of topics. The number of topics largely determines the performance quality of the model, so appropriate adjustments are required in different scenarios. In this paper, the perplexity method is used to measure the quality of the selected number of topics. Perplexity is an indicator used to evaluate the model's fit. The lower the perplexity, the better the model's performance when predicting unseen text data.
[0114] Specifically, the domain service clustering model and a given description document set (i.e., the test set) are used as input to calculate the topic perplexity, and the topic perplexity is used as the number of topics in the domain service clustering model;
[0115] The calculation formula of topic perplexity is as follows:
[0116]
[0117] Where: D represents the number of documents in a given description document set; N drepresents the number of words describing the dth document; p(DS d ) represents the predicted probability of the domain service clustering model for the dth description document.
[0118] When calculating perplexity, the negative value of the log-likelihood function is usually used as a measure of perplexity. The lower the perplexity, the better the model fits the test set, that is, the model can more accurately predict the documents in the test set. In practical applications, there is often an inverted U-shaped relationship between perplexity and the number of topics, that is, within a certain range, the perplexity first decreases and then increases with the increase in the number of topics. Therefore, we will choose the number of topics that minimizes the perplexity as the optimal number of topics. However, when the number of topics is too large, the model tends to overfit, which will lead to poor performance on unseen data. In order to avoid this problem and improve the generalization ability and prediction performance of the model, the present invention adopts the number of topics of the local optimal solution of the perplexity curve as the optimal number of topics for the model.
[0119] The present invention uses the LDA model to cluster microservices by topic and feature words, which has many advantages. For example, LDA can reduce the dimensionality of high-dimensional text data to a low-dimensional topic space; LDA can automatically assign a set of feature words to each topic and provide a brief label to help us understand the meaning of the topic. Figure 2 、 Figure 3 The brief production process of microservice documentation is described, and the specific process is shown in the following algorithm.
[0120]
[0121] In the algorithm, the input hyperparameters α and β represent the Dirichlet distribution of document-topic and topic-feature word respectively; the formula in step 5 indicates that the sampling probability is related to the topic distribution of the current feature word, document, and other feature words; finally, the topic distribution parameter θ of the document and the vocabulary distribution parameter of the topic are estimated by statistically obtaining the topic distribution. Here, Dirichlet distribution is used to model the distribution of parameters. At this point, the service description document generated based on LDA is complete, and we have obtained the probability distribution of document-topic and topic-feature word.
[0122] In the specific implementation process, considering that the vector space of microservices and rule feature vocabulary is not large in scale and dimension, the present invention adopts a cosine similarity calculation method with high computational efficiency. By setting a similarity threshold, a set of candidate rules that meets the requirements is generated. The specific steps are as follows:
[0123] S401: Determine the feature word column vector SV of the microservice topic i And the feature word column vector RV of the rule topic j ;
[0124] S402: SV i With RV j All the feature words in are merged into one word set, and SV is calculated i With RV j The word frequency vector SV i ′ and RV j ';
[0125] S403: RV j ′ Synthesize into a regular feature word probability distribution matrix SM;
[0126] The formula is:
[0127]
[0128] Where: a represents the total number of rules, satisfying 0≤j≤a;
[0129] S404: Column vector SV i ′ performs a dot product operation with each row of the matrix SM to obtain the dot product result Dot products ;
[0130] The formula is:
[0131]
[0132] S405: Calculate vector SV i The Euclidean norm of ′
[0133] S406: Calculate the Euclidean norm of each row of the matrix SM
[0134] S407: Use dot product result Dot products Calculate the cosine similarity with the Euclidean norm and get Cosine similarity[j] vector;
[0135] The formula is:
[0136]
[0137] S408: Add the rules corresponding to the values of the Cosine_similarity vector that meet the set similarity threshold STH to the candidate rule set, thereby completing the generation of the candidate rule set.
[0138] During implementation, rule priority levels are defined as three tiers: general, topic, and user-defined, denoted by LG, LF, and LC, respectively. Each tier has a strict link order, with priority decreasing from left to right. Each rule priority level is defined as a triple RL = (I, {R}, O), where I represents the number of levels in the rule priority hierarchy, {R} represents the set of all rules in that level, and O represents the order constraint between that rule level and other rule levels. The priority level to which a rule should belong is defined by the rule maker or user based on experience.
[0139] According to the flexible characteristics of the rule node, it is defined as a four-tuple RN = (NN, NL, ND, NL). It is assumed that RN is the indivisible minimum logical unit, that is, the atomic rule, where: NN represents the rule node code, which is used to determine the uniqueness of the rule node; NL represents the rule priority level to which the rule node belongs, which is determined by the rule engine or customized by the user; ND represents the rule node function description document, for example: "This node is used to filter services that meet the time cost requirements"; NL represents the constraint relationship between rule nodes, which can be defined as a triple NL = (PR, CR, SR), where PR is the preceding rule set, CR is the conflicting rule set, and SR is the following rule set.
[0140] The feature of rule chain triggered by message events is the key to realize dynamic configuration of services. After the rule node filter set is determined, they need to be chained according to a certain algorithm. A rule chain is defined as a triple RC = (M, R*, RR), where M represents the message event library, including message events such as microservice filtering requests, microservice updates, and microservice failures, which are used to trigger the operation of the rule chain; R* represents the rule node set contained in the rule chain, and R* should satisfy RR represents the rule constraints for generating rule chains.
[0141] Define the Rule Set Generation Model (RSGM), and define RSGM as a five-tuple RSGM = (SV i ,RV j ,SCM,RS,STH) among which,SV i Represents the feature word column vector of the i-th service, which is composed of the topic-feature word probability distribution of the microservice, SV i =(SW j1 ,SW j2 ,…,SW jn ) T , where SW represents the proportion of feature words in the i-th microservice topic; RV j Represents the feature word vector of the jth rule, which is composed of the probability distribution of the feature words of the rule, RV j=(RW j1 ,RW j2 ,…,RW jm ), where RW represents the proportion of feature words in the jth rule; SCM represents the similarity calculation method between microservices and rule vectors, including cosine similarity, KL divergence, Jensen-Shannon divergence, etc.; RS represents the rule set, which is used to store successfully matched rules; STH represents the similarity threshold, and rules that meet the threshold requirements will be included in RS.
[0142] specific;
[0143] 1) Rule constraints include inter-layer relationship constraints, where the inter-layer relationship constraints consider the number of layers of rule priority levels;
[0144] When generating a rule chain, the rules in the alternative rule set are linked in order of priority: general level, subject level, and user-defined level.
[0145] 2) Rule constraints include intra-layer relation constraints, where the intra-layer relation constraints consider the pre-rule set P of the rule R , conflict rule set C R With the post-rule set S R ;
[0146] When generating a rule chain, the intra-layer rule chain RC should satisfy the relationship described by the following formula:
[0147]
[0148] Where: (RN q ∈RN q+1 .P R )∪(RN q+1 ∈RN q .S R ) indicates that the previous rule is in the preceding rule set of the subsequent rule, or the subsequent rule is in the post-rule set of the previous rule; Indicates that neither rule is in the other's conflicting rule set.
[0149] 3) For other cases, just link them in sequence according to the position relationship in the RS vector.
[0150] In order to better illustrate the advantages of the technical solution of the present invention, this embodiment discloses the following experiments.
[0151] This experiment uses the actual public dataset Patent Dataset and actual automobile parts supply chain information to test the supply chain text information multi-level classification model (HAHMC) proposed in this invention.
[0152] 1. Dataset
[0153] The experimental data comes from the IFLYTEK public dataset in Github, including more than 17,000 long text annotation data of application microservice descriptions and 4,782 rule nodes in the Node-Red rule engine tool, which are manually annotated short text descriptions of rules. The data are shown in Tables 1 and 2.
[0154] Table 1 Microservice long text description
[0155]
[0156] Table 2 Short text description of rules
[0157]
[0158]
[0159] 2. Experimental Setup
[0160] All experiments and algorithms in this paper were implemented in Python. The topic-feature word probability distribution based on the LDA model was primarily based on the jieba and gensim libraries, and the visualization was primarily based on the pyLDAvis library. All experiments were run on a PC with an Intel(R) Core(TM) i5-10600KF CPU @ 4.10GHz, 16GB of RAM, and Windows 10.
[0161] 3. Effect indicators
[0162] 1) Optimal number of topics
[0163] For topic models, once the selected algorithm is determined, the hyperparameter that needs to be manually determined is usually the number of topics. The number of topics largely determines the performance quality of the model, so appropriate adjustments need to be made in different scenarios. In this invention, a method of calculating perplexity is used to measure the quality of the number of selected topics. Perplexity is an indicator used to evaluate the model fitting effect. The lower the perplexity, the better the performance of the model when predicting unseen text data. The calculation formula of perplexity is expressed as follows:
[0164]
[0165] Where D is the number of documents in the test set, N d is the number of words in the d-th document, p(DS d) is the model's predicted probability for the d-th document. When calculating perplexity, the negative value of the log-likelihood function is usually used as a measure of perplexity. The lower the perplexity, the better the model fits the test set, that is, the model can more accurately predict the documents in the test set. In practical applications, there is often an inverted U-shaped relationship between perplexity and the number of topics, that is, within a certain range, the perplexity first decreases and then increases with the increase in the number of topics. Therefore, we will choose the number of topics that minimizes the perplexity as the optimal number of topics. However, when the number of topics is too large, the model tends to overfit, which will lead to poor performance on unseen data. In order to avoid this problem and improve the generalization ability and prediction performance of the model, the present invention adopts the number of topics of the local optimal solution of the perplexity curve as the optimal number of topics for the model.
[0166] 2) Topic distribution characteristics
[0167] By using the method used in the present invention, we can obtain the topic distribution characteristics of the microservice document collection and select the topic distribution with the smallest overlap of different topics among all the results as the basis for subsequent experiments.
[0168] 3) Feature word vector similarity
[0169] Considering that the vector space of microservices and rule feature vocabulary is not large in scale and dimension, the present invention adopts a cosine similarity calculation method with high computational efficiency. By setting a similarity threshold, a rule set that meets the requirements is generated. The similarity is calculated as follows:
[0170]
[0171] 4) Microservice Composition Efficiency
[0172] The method of the present invention aims to discover and dynamically screen and manufacture microservices according to the needs of the enterprise (user), thereby improving the efficiency of subsequent microservice combination. Therefore, this method is of great significance to improving the efficiency of subsequent microservice combination, so the corresponding time of microservice combination is selected as the indicator.
[0173] 4. Experimental results
[0174] 1) Optimal number of topics
[0175] pass Figure 4 It can be seen that the perplexity curve shows a downward trend as the number of topics increases, but when the number of topics is 8, a local optimal solution appears. Therefore, the number of topics is temporarily set as 8 as the input of the LDA model.
[0176] 2) Topic-feature word probability distribution
[0177] Figure 5The result of the probability distribution of topics and feature words is shown in Figure 1. Each circle on the left represents a topic obtained by classification, including multiple microservices in the same field. The fewer the intersections between circles, the lower the overlap between topics, indicating that the classification results are better. The experimental results of (a), (b), (c), and (d) respectively show the corresponding topic-feature word probability distribution results when the number of topics input to the LDA model is 7, 8, 9, and 10, respectively. It can be seen from the overlap of circles on the left side of the figure that when the number of topics input is 7, 9, and 10, there is a large overlap, while when the number of topics input is 8, there is only a small overlap between topics. The reason may be that some stop words have not been removed or the domain characteristics of some non-stop words are not obvious. Therefore, we choose the result when the number of topics input is 8 as the basis for subsequent experiments. The bar chart on the right represents the probability distribution of each feature word in a topic. Figure 6 The 8th topic in the model can be judged from its high-frequency feature words such as production, data, equipment, and efficiency. This microservice topic is related to the manufacturing field, and the feature words rarely include words reflecting other fields, indicating that the model solution result is good.
[0178] 3) Rule matching and rule chain generation
[0179] according to Figure 6 The 8 microservice topics generated in the experiment are numbered 1-8, and the word frequency vectors of the rule nodes are also numbered 1-4782. The cosine similarity is calculated between each two and the similarity between the 8 topics and the first 20 rule nodes is displayed as follows: Figure 7 As shown, the similarity threshold sth is set to 0.3, and all rule nodes matching the manufacturing field (topic 8) are obtained as follows Figure 8 , forming the alternative rule set RS.
[0180] Select some rule nodes in the generated RS and generate a rule chain according to the predetermined rule chain generation method. Figure 9 The configuration of each node is shown in Table 3.
[0181] Table 3 Rule node configuration
[0182]
[0183] In the table, the Switch node is a user-defined type. Enterprises need to flexibly adjust it according to the actual needs of the manufacturing site within the operating range of existing service data. Due to the mechanism of rule chain message triggering, the needs of dynamic screening of microservices are met. The final screening results are as follows: Figure 10 shown.
[0184] 3) Validation
[0185] In order to verify the effectiveness of the method of the present invention, a combination comparison experiment was conducted using the traditional genetic algorithm alone as the basis and the microservice data processed by the method of the present invention (LDA-RC). The response time of the combination was used as the comparison indicator. The experimental results are as follows: Figure 11 As shown in the results, it can be seen that the method of the present invention can reduce the time of microservice combination to a certain extent, because the method can automatically filter out most of the meaningless microservices.
[0186] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the technical solutions. Those skilled in the art should understand that modifications or equivalent replacements of the technical solutions of the present invention that do not depart from the purpose and scope of the technical solutions of the present invention should be included in the scope of the claims of the present invention.
Claims
1. A manufacturing microservice discovery and dynamic screening method based on LDA and rule chain, characterized by: include: S1: Build a domain service clustering model using the LDA algorithm and train and solve the domain service clustering model; In step S1, the input of the domain service clustering model is the description document, and the output is the document-topic probability distribution and topic-feature word probability distribution of the description document; The domain service clustering model generates a reconstructed document set consisting of feature words based on the input description document set, where the joint probability distribution P of the reconstructed document and the description document is expressed as: Where: P is the joint probability distribution, which represents the probability that the reconstructed document generated by the domain service clustering model is consistent with the description document; Indicates that the topic distribution parameter θ is calculated for each description document J J The probability of , M is the number of documents; Indicates that the characteristic word distribution parameters are calculated for each topic I The probability of; K is the number of topics; Indicates that the topic Z is calculated for each position t of each description document j j,t probability; Indicates that the feature word W is calculated for each position t of each description document j j,t probability; S2: Obtain a microservice set containing several microservice description documents and input them into the domain service clustering model. Output the topic-feature word probability distribution of all microservices, and then construct the feature word column vector of the microservice topic. S3: Obtain a rule set containing several rule description documents and input it into the domain service clustering model. Output the topic-feature word probability distribution of all rules, and then construct the feature word column vector of the rule topic. S4: By calculating the similarity between the feature word column vectors of the microservice topic and the rule topic, we match the rules with similar semantics to the microservice, and then filter out the rules that meet the conditions and put them into the candidate rule set; S5: Generate a rule chain based on the candidate rule set and the set rule constraints. Use the message event triggering mechanism of the rule chain to achieve microservice discovery and dynamic screening. In step S5, the rule constraints include inter-layer relationship constraints, wherein the inter-layer relationship constraints take into account the number of layers of the rule priority level; When generating a rule chain, the rules in the candidate rule set are linked in order of priority: general level, subject level, and user-defined level; In step S5, the rule constraints include intra-layer relationship constraints, wherein the intra-layer relationship constraints consider the pre-rule set P of the rule R , conflict rule set C R With the post-rule set S R ; When generating a rule chain, the intra-layer rule chain RC should satisfy the relationship described by the following formula: Where: (RN q ∈RN q+1 .P R )∪(RN q+1 ∈RN q .S R ) indicates that the previous rule is in the preceding rule set of the subsequent rule, or the subsequent rule is in the post-rule set of the previous rule; Indicates that neither rule is in the other's conflicting rule set; RN indicates an atomic rule.
2. The method for discovering and dynamically screening manufacturing microservices based on LDA and rule chaining according to claim 1, characterized in that: In step S1, the domain service clustering model is trained and solved using the Gibbs sampling method to obtain the document-topic probability distribution and the topic-feature word probability distribution. The specific steps are as follows: S101: Randomly assign an initial topic to each word in the description document; S102: For each word in each description document, perform the following steps in sequence: S1021: Randomly select a word w that describes document d and record its current topic as z; S1022: Remove the association count between word w and topic z from description document d; S1023: Considering the topic distribution of other words in the description document d and the topic distribution of word w in other description documents, calculate the conditional probability distribution of the possible topic distribution of word w; S1024: Reassign a topic k to word w according to the conditional probability distribution of topic distribution; S1025: Update the association count between word w and topic k in description document d; S103: Repeat step S102 to implement iteration until the domain service clustering model converges or the number of iterations is reached; S104: After the domain service clustering model is trained and solved using the Gibbs sampling method, each word is assigned a topic: the number of occurrences of each topic in each document is counted to obtain a document-topic probability distribution; the number of occurrences of each word under each topic is counted to obtain a topic-feature word probability distribution.
3. The method for discovering and dynamically screening manufacturing microservices based on LDA and rule chaining according to claim 2, characterized in that: In step S2, based on the topic-feature word probability distribution of all microservices, the feature word proportion corresponding to each microservice topic is calculated to form the feature word column vector of the microservice topic, where the feature word column vector SV of the i-th microservice topic is i =(SW i1 ,SW i2 ,...,SW in ) T , SW in Indicates the proportion of the nth feature word in the i-th microservice topic; In step S3, based on the topic-feature word probability distribution of all rules, the feature word ratio corresponding to each rule topic is calculated to form the feature word column vector of the rule topic, where the feature word column vector RV of the jth rule topic is j =(RW j1 ,RW j2 ,…,RW jm ), RW jm Indicates the proportion of the mth feature word in the jth microservice topic.
4. The method for discovering and dynamically screening manufacturing microservices based on LDA and rule chaining according to claim 1, characterized in that: In step S1, the domain service clustering model and a given description document set are used as input to calculate the topic perplexity, and the topic perplexity is used as the number of topics in the domain service clustering model; The calculation formula of topic perplexity is as follows: Where: D represents the number of documents in a given description document set; N d represents the number of words describing the dth document; p(DS d ) represents the predicted probability of the domain service clustering model for the dth description document.
5. The method for discovering and dynamically screening manufacturing microservices based on LDA and rule chaining according to claim 1, characterized in that: In step S4, a candidate rule set is generated through the following steps: S401: Determine the feature word column vector SV of the microservice topic i And the feature word column vector RV of the rule topic j ; S402: SV i With RV j All the feature words in are merged into one word set and SV is calculated. i With RV j The word frequency vector SV i ′ and Rv j '; S403: RV j ' is synthesized into a regular feature word probability distribution matrix SM; The formula is: Where: a represents the total number of rules, satisfying 0≤j≤a; S404: Column vector SV i ′ performs a dot product operation with each row of the matrix SM to obtain the dot product result Dot products ; The formula is: S405: Calculate vector SV i The Euclidean norm of ′ S406: Calculate the Euclidean norm of each row of the matrix SM S407: Use dot product result Dot products Calculate the cosine similarity with the Euclidean norm and get Cosine similarity[j] vector; The formula is: S408: Cosine similarity[j] The rules corresponding to the values reaching the similarity threshold STH are added to the candidate rule set.
6. The method for discovering and dynamically screening manufacturing microservices based on LDA and rule chaining according to claim 1, characterized in that: In step S5, after the rule chain is generated, the symbols and values of each rule node in the rule chain are adjusted according to its own needs to complete the dynamic screening of microservices.
Citation Information
Patent Citations
Control method and device based on micro service
CN114637266A
Service discovery method based on clustering and Gaussian LDA
CN111832289A
Product typicality characteristic mining method and system based on theme integration clustering
CN114792246A