Web API recommendation method based on multi-channel hypergraph convolutional network
Through the method based on multi-channel hypergraph convolutional network, the service hypergraph structure is extracted and the convolution weight matrix is optimized, which solves the data sparsity and noise problems in Web API recommendations, and realizes high-precision Web API recommendations.
Patent Information
- Application Number
- CN202411681845.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-11-22
AI Technical Summary
In the case where the relationship between service data tag carrying and calling is complicated, it is difficult to effectively recommend Web APIs, and there is a problem of data sparseness.
Using the Web API recommendation method based on multi-channel hypergraph convolution network, the service hypergraph structure is extracted through the model, the convolution weight matrix is optimized using a hybrid random walk algorithm, and the noise is reduced, and convolution is performed on the constructed hypergraph. Finally, the convolution results on different channels are merged to obtain the service representation vector.
It improves the accuracy of Web API recommendations, effectively solves the problem of data sparseness, and enhances the robustness of the recommendation system.
Smart Images

Figure CN119760217A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of service recommendation scenarios under Mashup development, and specifically relates to a Web API recommendation method based on a multi-channel hypergraph convolutional network. Background Art
[0002] With the development of service-oriented computing (SOC) and cloud computing, Web services have become an important carrier for IT resource delivery. SOC is committed to using services as basic building blocks to create fast, low-cost, secure and reliable applications. Services not only simplify the software development and maintenance process, but also provide a solid foundation for cross-platform and cross-system integration.
[0003] In recent years, more and more developers have benefited from the reuse of Web services, usually in the form of Web APIs. Web API is an application programming interface that allows Web applications to access and implement storage services, messaging services, computing services, and other functions. For example, technology giants such as Google and Microsoft are opening their software and data resources to the public as Web services through WebAPIs to attract a wider range of Internet users.
[0004] As the Web API economy continues to flourish, many Web API sharing repositories have emerged in the market, among which ProgrammableWeb is one of the largest Web API repositories. Specifically, statistics as of May 2021 show that there are at least 24,000 publicly accessible Web APIs in more than 400 categories of services registered and published on ProgrammableWeb. More and more developers benefit from the reuse of Web services, and Mashup technology that uses Web APIs as reusable components to create new products has emerged. This phenomenon clearly marks the arrival of a new era of using big data to promote application development.
[0005] Web API recommendation methods emerge in an endless stream. In the existing research, some methods use traditional collaborative filtering or its extended model to use service collaborative information or auxiliary information of the service itself for service recommendation. Ren et al. constructed the service composition problem as a Markov decision process and incorporated the service bearer information. This method significantly improves the adaptability to the uncertain behavior of services in dynamic environments and solves the QoS constraint problem of users. There are also methods that model Mashup services and Web APIs through machine learning and implement recommendations. Wu et al. not only used Convolutional Neural Network (CNN) as the basic component for feature extraction in service description documents, but also introduced feature interaction components to characterize the interaction information between Mashup and API. Sang et al. considered contextual information, integrated it into the interaction data to alleviate the data sparsity problem, and used adversarial training to enhance the robustness of the model.
[0006] In recent years, Graph Neural Networks (GNN) have achieved great success in many fields. Thanks to its outstanding ability in relational data modeling, GNN-based models have also shown excellent potential in the field of service recommendation systems. Hypergraphs generalize the concept of edges in traditional graphs, allowing edges to connect more than two nodes, providing an intuitive and natural framework for modeling complex high-order relationships between services, and can effectively extract high-order relationships on service hypergraphs through node-edge conversions. Summary of the invention
[0007] In order to overcome the shortcomings of the prior art, the present invention proposes a Web API recommendation method based on a multi-channel hypergraph convolutional network in view of the complex characteristics of service data label carrying and calling relationship. Firstly, the hypergraph structure is extracted from the service by using the motif, and the complex relationship between service data is studied. Then, in order to reduce the introduction of noise, a convolution weight matrix guided by a hybrid random walk is used in the hypergraph convolution. Finally, according to the obtained weight matrix, convolution is performed on the constructed hypergraph. Finally, the convolution results on different channels are merged to obtain the representation vector of the service, and the Web API is recommended with high accuracy.
[0008] The present invention provides the following technical solutions:
[0009] A Web API recommendation method based on a multi-channel hypergraph convolutional network, the method comprising the following steps:
[0010] The first step is to extract the service hypergraph based on the service motif. The process is as follows:
[0011] Step (1.1) crawl Mashup service information from relevant API websites;
[0012] Step (1.2) analyzes the crawled Mashup service set and selects meta-information that is helpful to improve the accuracy of service recommendation and is rich in content;
[0013] Step (1.3) summarizes four types of motifs: co-correlation motifs, multiple strong correlation motifs, single relationship motifs, and complex relationship motifs;
[0014] Step (1.4) constructs a multi-channel hypergraph based on the motif proposed in step (1.3);
[0015] The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph through the hybrid random walk algorithm;
[0016] Among them, random walk is a mathematical statistical model, which consists of a series of trajectories and is a random process. In random walk, each step of movement is based on random factors rather than predetermined rules. After the hypergraph extraction based on the motif structure, the current neighborhood division is relatively rough. Directly convolving the hypergraph is prone to introduce noise. A hypergraph convolution weight matrix can be calculated through random walk to optimize the hypergraph convolution. The process is as follows:
[0017] Step (2.1) proposes a hybrid random walk algorithm based on the combination of partial absorption random walk and biased random walk to calculate the convolution weight matrix C on the hypergraph;
[0018] Step (2.2) is further obtained according to the weight calculation formula: Λ(CI)+CD=(W⊙Q)C, where Λ is a regularized matrix with all values greater than 0, D represents the degree matrix of the hypergraph, which is a diagonal matrix whose diagonal elements represent the degrees of the corresponding vertices; W represents the weights between nodes determined by the degrees, and Q is a parameter matrix used to adjust the transition probability in the biased random walk;
[0019] Step (2.3) is further calculated to deduce the closed form of the convolution weight matrix C = (Λ + L) -1 Λ; where L = DW⊙Q;
[0020] Step 3: Perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the embedded expression of the Mashup;
[0021] Step 4: Use Bert to encode the API according to its description document to obtain the embedded expression Y of the API a ;
[0022] Step 5: Optimize the model based on the model recommendation results.
[0023] Furthermore, in the step (1.2), the retained meta-information includes Mashup, API, the calling relationship between Mashup and API, and the tags carried by Mashup;
[0024] The Mashup set is defined as M = {m1,m2,…,m N}, where N is the total number of Mashups in the collection, Mashup m i The API set called is A i ={a i,1 ,a i,2 ,a i,3 ,…,a i,k}, k is Mashup m i The total number of APIs called. The set of APIs called by all Mashups is Where ∪ means finding the union of all sets; Mashup-API call relationships are stored in a 0-1 matrix In which, each pair of Mashup m and API a, t m,a =1 indicates that Mashup m has a calling relationship with API a, t m,a =0 means there is no calling relationship between Mashup m and API a;
[0025] Among them, the label represents part of the function or attribute of the Mashup. The label information contains the collaborative information between the Mashup and the API. Therefore, the feature mining process of the API and Mashup not only uses the call information but also the label information. To represent the relationship between labels and Mashup, each pair of Mashup m and label ta involved, R m,ta =1 means that Mashup m and tag ta have a carrying relationship, R m,ta =0 means that there is no carrying relationship between Mashup m and tag ta.
[0026] Furthermore, in step (1.3), motifs represent connection patterns that appear repeatedly in the network and are significantly higher in number than other complex networks. Such connection patterns often contain key information about the network. A large number of studies have proven that motifs have a substantial ability to bridge the gap between microscopic and macroscopic structural information.
[0027] The descriptions of the four motifs are as follows:
[0028] Co-associated motifs: In the Mashup call scenario, there are two Mashups that carry the same label, which is called a same-label relationship. In the service data, there are Mashups that have the same label relationship between each other and form a ternary closure structure, which is called a co-associated motif.
[0029] The ternary closure is a concept in social network theory, which refers to a property of a triple consisting of three nodes A, B, and C, that is, there is a strong connection between A and B, A and C, and B and C.
[0030] Multiple strong correlation motifs: Labels are diverse and artificially defined, which causes uncertainty in the labels carried by Mashups. A pair of Mashups carrying two or more identical labels is defined as a strong correlation, and a closed-loop structure with strong correlations between multiple Mashups is defined as a multiple strong correlation motif.
[0031] Single relationship motif: The calling relationship between Mashup and API presents the functional characteristics of Mashup. Two Mashups that call the same API have functional similarities. The motif of two Mashups calling the same API is defined as a single relationship motif.
[0032] Composite relationship motif: Mashups call the same API and carry the same label. In order to use this feature to explore the relationship between mashups, mashups that call the same API and have the same label relationship are defined as composite relationship motifs.
[0033] Furthermore, in step (1.4), the hypergraph is a generalization of the traditional pairwise relationship graph. In traditional graph theory, a graph consists of nodes (vertices) and edges, while the hypergraph introduces the concept of hyperedges. A hyperedge is a collection of nodes connected, not just two nodes, which enables the hypergraph to better describe complex relationships and high-order associations; motifs are used to construct a multi-channel hypergraph, where each motif constitutes a hyperedge, and the process is as follows:
[0034] Step (1.4.1) constructs the hypergraph G1 based on the “co-correlation motifs”, the process is as follows;
[0035] Step (1.4.1.1) Calculate the relationship matrix R based on the Mashup-label relationship matrix Perform step (1.4.1.2);
[0036] in, Indicates the number of identical labels between Mashups. " indicates the transposition of the matrix;
[0037] Step (1.4.1.2) construct the upper triangular matrix R *, used to indicate whether the mashups carry the same tags, and proceed to step (1.4.1.3);
[0038] Among them, R * By matrix Take the upper right corner of the diagonal and set all numbers greater than 0 to 1;
[0039] Step (1.4.1.3) calculates the adjacency matrix of the hypergraph G1;
[0040] The adjacency matrix is a matrix that represents the adjacent relationship between vertices in the hypergraph. The calculation formula of the adjacency matrix S1 of the hypergraph G1 is S1 = (R * R * )⊙R * . Among them, ⊙ represents the Hadamard product of the left and right matrices;
[0041] Step (1.4.2) constructs the hypergraph G2 based on the “multiple strongly correlated motifs”, the process is as follows;
[0042] Step (1.4.2.1) Construct the matrix R ′ , used to indicate whether the mashups carry two or more identical tags, and then proceed to step (1.4.2.2);
[0043] Among them, the matrix R ′ By taking the matrix The upper right diagonal is constructed by setting all numbers greater than 2 to 1 and the rest to 0;
[0044] Step (1.4.2.2) calculates the adjacency matrix of the hypergraph G2;
[0045] Step (1.4.3) constructs the hypergraph G3 based on the “single relation motif”, the process is as follows;
[0046] Step (1.4.3.1) is calculated based on the Mashup-API call relationship matrix T Perform step (1.4.3.2);
[0047] in, Indicates the number of calls to the same API between Mashups;
[0048] Step (1.4.3.2) is based on the matrix Calculate the matrix T * , proceed to step (1.4.3.3);
[0049] Among them, the matrix T * By taking the matrix The upper right corner of the diagonal line is constructed by setting all numbers greater than 0 to 1, indicating whether the same API is called between mashups;
[0050] Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3;
[0051] The calculation formula of the adjacency matrix S3 of the hypergraph G3 is S3 = T * T *" ;
[0052] Step (1.4.4) Based on the “composite relational motif”, the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R * Find the Hadamard product, calculate the adjacency matrix of the hypergraph G4 and construct the hypergraph G4;
[0053] The calculation formula of the adjacency matrix S4 of the hypergraph G4 is S4=(T * T *" )⊙R * , which means filtering out Mashup pairs that do not carry the same label.
[0054] Preferably, the process of step (1.4.2.2) is:
[0055] Step (1.4.2.2.1) defines the adjacency matrix S2 to represent the adjacency matrix of the hypergraph G2;
[0056] Step (1.4.2.2.2) traverses the Mashup set M, and initializes the value i to 1 to record the Mashup number, and performs steps (1.4.2.2.2.1-1.4.2.2.2.3) to calculate all values of the i-th row in S2. The process is as follows;
[0057] Step (1.4.2.2.2.1) traverses the Mashup set M and initializes the value j to 1 to record the Mashup number and calculates S2 in S2 i,j The value of , the process is;
[0058] Among them, S2 i,j represents the value of the i-th row and j-th column in the adjacency matrix S2;
[0059] Step (1.4.2.2.2.1.1) queries the matrix R to confirm whether the number of identical tags carried by Mashup i and Mashup j is greater than 1. If so, replace S2 i,j Set to 1, otherwise set to 0 and proceed to step (1.4.2.2.2.1.2);
[0060] In step (1.4.2.2.2.1.2), take j=j+1 and proceed to step (1.4.2.2.2.1.3);
[0061] Step (1.4.2.2.2.1.3) determines whether j is less than or equal to N. If so, return to step (1.4.2.2.2.1.1), otherwise exit the loop;
[0062] In step (1.4.2.2.2.2), let i=i+1 and proceed to step (1.4.2.2.2.3);
[0063] Step (1.4.2.2.2.3) determines whether i is less than or equal to N. If so, return to step (1.4.2.2.2.1), otherwise exit the loop.
[0064] In (2.1), the convolution weight matrix in, represents the set of real numbers, c i,j represents the value of the i-th row and j-th column in matrix C, represents a matrix of size N×N composed of real numbers, ∈ represents the belonging relationship between elements and sets; the process is:
[0065] In order to avoid the random walk from converging to a stationary distribution determined only by the degree of each node, we refer to the partial absorption random walk and assume that the random process X = {X t :t≥0} is the transition probability matrix
[0066]
[0067] Among them, the partially absorbing random walk is a second-order Markov chain, which is characterized by a certain probability of staying in the current state or transitioning to the next state in each state, which is determined by the transition probability p i,j The global semantic structure of the topology is captured by the decision. Once the walk stops at a certain state, it will stay in that state forever, that is, it will be absorbed in the current state.
[0068] in, Among them, d i represents the degree of vertex i, which represents the number of edges connected to the vertex in the graph, S i,j represents the value of the i-th row and j-th column in the adjacency matrix S, λ i ∈Λ,Λ=diag(λ1,λ2,…,λ N ) is a regularized matrix with all values greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix, and the calculation formula of Λ is Λ=δI. Where I represents the unit matrix, δ represents the weight coefficient, and the absorption probability between nodes can be adjusted by adjusting δ;
[0069] Step (2.1.2) combines the parameter matrix Q with P to obtain the convolution weight calculation formula on the hypergraph
[0070]
[0071] Among them, Q is the parameter matrix used to adjust the transition probability in the biased random walk. The biased random walk combines the breadth-first and depth-first sampling strategies to adjust the transition probability, so as to achieve the purpose of balancing homogeneity and structural equivalence, and can flexibly search for complex network structures. The element q in the i-th row and j-th column of the matrix Q is i,j The calculation formula is
[0072] Among them, breadth-first and depth-first are two common search strategies. The breadth-first strategy traverses the graph or tree structure layer by layer in a hierarchical manner, first visiting all adjacent nodes, and then visiting the nodes in the next layer in turn. It is suitable for finding the shortest path. The depth-first strategy explores down along a branch to the end, and then traces back to the previous branch. It is suitable for finding all possible solutions. i,j represents the shortest distance between nodes i and j, and p and q are parameters for adjusting the walking strategy. Among them, homogeneity means that two nodes belonging to the same cluster are more similar, and structural equivalence means that two nodes with the same structural role are more similar.
[0073] The process of step three is as follows:
[0074] Step (3.1) combines the convolution weight matrix with the traditional hypergraph convolutional network. Based on LightGCN, the feature transformation and activation function are discarded, the convolution operation is simplified, and the convolution operation is defined as X (l+1) =D (-1) SX (l) ;
[0075] Among them, LightGCN is a recommendation algorithm based on graph neural network. It improves efficiency and performance by simplifying the model structure. It is easy to understand and explain and is widely used. Feature transformation refers to the method of obtaining new features through certain rules or mappings of the original features. The activation function refers to the functional relationship between the output of the upper node and the input of the lower node in the multi-layer neural network. (l) and X (l+1) Represents the input and output of a single convolution, S represents the adjacency matrix, D (-1) represents the inversion of matrix D;
[0076] Step (3.2) introduces the convolution weight matrix C and performs the hypergraph convolution operation;
[0077] Among them, the single-layer convolution formula is X (l+1) =CX (l) , the convolution formula of the hypergraph convolutional network with L layers of convolution is y (L) =C…(CX(0) );
[0078] in, represents the input matrix composed of the embedding matrices of the hypergraph vertices. Since the present invention adopts a multi-channel hypergraph convolutional network, C in the formula can be replaced by the convolution weight matrices C1, C2, C3 and C4 of the hypergraphs G1, G2, G3 and G4 to obtain the output result y1 (L) ,y2 (L) ,y3 (L) 、y4 (L) ;
[0079] Where s represents the embedding length.
[0080] Step (3.3) averages the output of each convolution to obtain the final output of each channel;
[0081] Among them, y n The calculation formula is
[0082] Step (3.4) aggregates the output of each channel to obtain the embedded expression Y of the Mashup m ;
[0083] Among them, the aggregation between channels introduces the channel attention module to realize channel attention. Among them, the channel attention module is a commonly used attention mechanism module in deep learning. It can improve the performance of the model by strengthening the channel features of the input feature map. Its core lies in its ability to learn the relationship between different channels and dynamically adjust the weights of different channels.
[0084] The process of step five is as follows:
[0085] Step (5.1) scores the matching degree between the embedded expression of the Mashup and the embedded expression of the API, and obtains the top K matching APIs;
[0086] Among them, Mashup m i with API a j Matching score between By calculating Y m and Y a The inner product between them is obtained;
[0087] Step (5.2) calculates the loss of the model and adjusts the parameters of the model;
[0088] Among them, BPR loss is used to represent the loss of the recommendation model. BPR loss is a loss function used to learn user personalized preferences in recommendation systems, which can make positive samples rank higher than negative samples. Among them, positive samples represent API samples actually called by the current Mashup, and negative samples represent API samples that are not actually called by the current Mashup. The calculation formula of the loss function is:
[0089]
[0090] in, Represents Mashup m i with API a j Matching score, Represents Mashup m i with API a k where log represents the logarithmic function, σ represents a learnable weight matrix, and Φ represents the model parameters.
[0091] The beneficial effect of the present invention is that the complex high-order relationships between services are effectively extracted through the motif, and the high-order associations between Mashup and API are deeply mined, which effectively solves the problem of data sparsity. Furthermore, the hypergraph convolutional network is used to model multiple nodes, which can intuitively describe the complex service calls and label carrying relationships; finally, by introducing a hybrid random walk method combining partial absorption random walk and biased random walk algorithm, the calculation process of the hypergraph convolution weight matrix is optimized, which effectively reduces the introduction of noise and improves the robustness of the recommendation system. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] Figure 1 The phantom structure of the present invention is shown.
[0093] Figure 2 The visualization comparison results of the embedding distances of positive and negative samples between the embedding method of the present invention and the LightGCN embedding method are shown. DETAILED DESCRIPTION
[0094] The present invention is further described below.
[0095] Reference Figure 1 , a Web API recommendation method based on a multi-channel hypergraph convolutional network, comprising the following steps:
[0096] The first step is to extract the service hypergraph based on the service motif. The process is as follows:
[0097] Step (1.1) crawl Mashup service information from relevant API websites;
[0098] Step (1.2) analyzes the crawled Mashup service set and selects meta-information that is helpful to improve the accuracy of service recommendation and is rich in content;
[0099] The retained meta information includes Mashup, API, the calling relationship between Mashup and API, and the tags carried by Mashup;
[0100] The Mashup set is defined as M = {m1,m2,…,m N}, where N is the total number of Mashups in the collection, Mashup m i The API set called is A i ={a i,1 ,a i,2 ,a i,3 ,…,a i,k}, k is Mashup m i The total number of APIs called. The set of APIs called by all Mashups is Where ∪ means finding the union of all sets, and the Mashup-API call relationship is stored in a 0-1 matrix In which, each pair of Mashup m and API a, t m,a =1 indicates that Mashup m has a calling relationship with API a, t m,a =0 means there is no calling relationship between Mashup m and API a;
[0101] The tag represents part of the functions or attributes of the Mashup. The tag information contains the collaborative information between the Mashup and the API. Therefore, the feature mining process of the API and Mashup uses not only the call information but also the tag information. The present invention uses a 0-1 matrix To represent the relationship between labels and Mashup, each pair of Mashup m and label ta involved, R m,ta =1 means that Mashup m and tag ta have a carrying relationship, R m,ta =0 means that there is no carrying relationship between Mashup m and tag ta;
[0102] Step (1.3) summarizes four types of motifs: co-correlation motifs, multiple strong correlation motifs, single relationship motifs, and complex relationship motifs;
[0103] Among them, motifs represent connection patterns that appear repeatedly in the network and are significantly higher in number than other complex networks. This connection pattern often holds key information about the network. A large number of studies have proven that motifs have a substantial ability to bridge the gap between micro- and macro-structural information.
[0104] The descriptions of the four motifs are as follows:
[0105] Co-associated motifs: In the Mashup call scenario, there are two Mashups that carry the same label, which is called the same label relationship in this invention. In the service data, there are Mashups that have the same label relationship between each other and form a ternary closure structure, which is called the co-associated motif;
[0106] The ternary closure is a concept in social network theory, which refers to a property of a triple consisting of three nodes A, B, and C, that is, there is a strong connection between A and B, A and C, and B and C.
[0107] Multiple strong correlation motifs: Labels themselves are diverse and artificially defined labels cause uncertainty in the labels carried by Mashups. The present invention defines the relationship between a pair of Mashups carrying two or more identical labels as a strong correlation relationship, and defines the structure in which multiple Mashups are strongly correlated with each other to form a closed loop as a multiple strong correlation motif;
[0108] Single relationship motif: The calling relationship between Mashup and API presents the functional characteristics of Mashup. Two Mashups that call the same API have functional similarities. The present invention defines the motif of two Mashups calling the same API as a single relationship motif.
[0109] Composite relationship motif: Mashups call the same API and carry the same label. In order to use this feature to explore the relationship between mashups, the present invention defines mashups that call the same API and have the same label relationship as composite relationship motifs;
[0110] Step (1.4) performs steps (1.4.1-1.4.4) to construct a multi-channel hypergraph based on the motif proposed in step (1.3);
[0111] Among them, the hypergraph is a generalization of the traditional pairwise relationship graph. In traditional graph theory, a graph consists of nodes (vertices) and edges, while the hypergraph introduces the concept of hyperedges; a hyperedge is a collection of multiple nodes connected, not just two nodes, which enables the hypergraph to better describe complex relationships and high-order associations. The present invention uses motifs to construct a multi-channel hypergraph, wherein each motif constitutes a hyperedge;
[0112] Step (1.4.1) constructs the hypergraph G1 based on the “co-correlation motif”. The process is:
[0113] Step (1.4.1.1) Calculate the relationship matrix R based on the Mashup-label relationship matrix Perform step (1.4.1.2);
[0114] in, Indicates the number of identical labels between Mashups. " indicates the transposition of the matrix;
[0115] Step (1.4.1.2) construct the upper triangular matrix R * , used to indicate whether the mashups carry the same tags, and proceed to step (1.4.1.3);
[0116] Among them, R * By matrix Take the upper right corner of the diagonal and set all numbers greater than 0 to 1;
[0117] Step (1.4.1.3) calculates the adjacency matrix of the hypergraph G1;
[0118] The adjacency matrix is a matrix that represents the adjacent relationship between vertices in the hypergraph. The calculation formula of the adjacency matrix S1 of the hypergraph G1 is S1 = (R * R * )⊙R * . Among them, ⊙ represents the Hadamard product of the left and right matrices;
[0119] Step (1.4.2) constructs the hypergraph G2 based on the “multiple strongly correlated motifs”. The process is as follows:
[0120] Step (1.4.2.1) constructs a matrix R′ to represent whether the mashups carry two or more identical tags, and proceeds to step (1.4.2.2);
[0121] Among them, the matrix R′ is obtained by taking the matrix The upper right diagonal is constructed by setting all numbers greater than 2 to 1 and the rest to 0;
[0122] Step (1.4.2.2): perform steps (1.4.2.2.1-1.4.2.2.2) to calculate the adjacency matrix of the hypergraph G2, and perform step (1.4.2.3);
[0123] Step (1.4.2.2.1) defines the adjacency matrix S2 to represent the adjacency matrix of the hypergraph G2, and proceeds to step (1.4.2.2.2);
[0124] Step (1.4.2.2.2) traverses the Mashup set M, and initializes the value i to 1 to record the number of the Mashup, and performs steps (1.4.2.2.2.1-1.4.2.2.2.3) to calculate all values of the i-th row in S2;
[0125] Step (1.4.2.2.2.1) traverses the Mashup set M and initializes the value j to 1 to record the Mashup number and calculates S2 in S2i,j The value of
[0126] Among them, S2 i,j represents the value of the i-th row and j-th column in the adjacency matrix S2;
[0127] Step (1.4.2.2.2.1.1) queries the matrix R to confirm whether the number of identical tags carried by Mashup i and Mashup j is greater than 1. If so, replace S2 i,j Set to 1, otherwise set to 0 and proceed to step (1.4.2.2.2.1.2);
[0128] In step (1.4.2.2.2.1.2), take j=j+1 and proceed to step (1.4.2.2.2.1.3);
[0129] Step (1.4.2.2.2.1.3) determines whether j is less than or equal to N. If so, return to step (1.4.2.2.2.1.1), otherwise exit the loop;
[0130] In step (1.4.2.2.2.2), let i=i+1 and proceed to step (1.4.2.2.2.3);
[0131] Step (1.4.2.2.2.3) determines whether i is less than or equal to N. If so, return to step (1.4.2.2.2.1), otherwise exit the loop;
[0132] Step (1.4.3) constructs the hypergraph G3 based on the “single relation motif”. The process is:
[0133] Step (1.4.3.1) is calculated based on the Mashup-API call relationship matrix T Perform step (1.4.3.2);
[0134] in, Indicates the number of calls to the same API between Mashups;
[0135] Step (1.4.3.2) is based on the matrix Calculate the matrix T * , proceed to step (1.4.3.3);
[0136] Among them, the matrix T * By taking the matrix The upper right corner of the diagonal line is constructed by setting all numbers greater than 0 to 1, indicating whether the same API is called between mashups;
[0137] Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3;
[0138] The calculation formula of the adjacency matrix S3 of the hypergraph G3 is S3 = T * T * ";
[0139] Step (1.4.4) Based on the “composite relational motif”, the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R * Find the Hadamard product, calculate the adjacency matrix of the hypergraph G4 and construct the hypergraph G4;
[0140] The calculation formula of the adjacency matrix S4 of the hypergraph G4 is S4=(T * T *" )⊙R * , which means filtering out mashup pairs that do not carry the same label;
[0141] The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph through the hybrid random walk algorithm;
[0142] Among them, random walk is a mathematical statistical model, which consists of a series of trajectories and is a random process. In the random walk, each step of movement is based on random factors rather than predetermined rules. After the hypergraph extraction based on the motif structure, the current neighborhood division is relatively rough. Directly convolving the hypergraph is prone to introduce noise. A hypergraph convolution weight matrix can be calculated through random walk to optimize the hypergraph convolution.
[0143] The process of the second step is as follows:
[0144] Step (2.1) proposes a hybrid random walk algorithm based on the combination of partial absorption random walk and biased random walk, and executes steps (2.1.1-2.1.2) to calculate the convolution weight matrix C on the hypergraph;
[0145] Among them, the convolution weight matrix in, represents the set of real numbers, c i,j represents the value of the i-th row and j-th column in matrix C, represents a matrix of size N×N composed of real numbers, ∈ represents the belonging relationship between elements and sets;
[0146] In order to avoid the random walk from converging to a stationary distribution determined only by the degree of each node, we refer to the partial absorption random walk and assume that the random process X = {X t :t≥0} is the transition probability matrix
[0147]
[0148] Among them, the partially absorbing random walk is a second-order Markov chain, which is characterized by a certain probability of staying in the current state or transitioning to the next state in each state, which is determined by the transition probability p i,j Decision, thus capturing the global semantic structure of the topology. Once the walk stops at a certain state, it will always remain in that state, that is, it is absorbed in the current state;
[0149] in, Among them, d i represents the degree of vertex i, which represents the number of edges connected to the vertex in the graph, S i,j represents the value of the i-th row and j-th column in the adjacency matrix S, λ i ∈Λ,Λ=diag(λ1,λ2,…,λ N ) is a regularized matrix with all values greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix. The calculation formula of Λ is Λ=δI, where I represents the unit matrix and δ represents the weight coefficient. By adjusting δ, the absorption probability between nodes can be adjusted. Step (2.1.2) combines the parameter matrix Q with P to obtain the convolution weight calculation formula on the hypergraph.
[0150]
[0151] Among them, Q is the parameter matrix used to adjust the transition probability in the biased random walk. The biased random walk combines the breadth-first and depth-first sampling strategies to adjust the transition probability, so as to achieve the purpose of balancing homogeneity and structural equivalence, and can flexibly search for complex network structures. The element q in the i-th row and j-th column of the matrix Q is i,j The calculation formula is
[0152] Among them, breadth-first and depth-first are two common search strategies. The breadth-first strategy traverses the graph or tree structure layer by layer in a hierarchical manner, first visiting all adjacent nodes, and then visiting the nodes in the next layer in turn. It is suitable for finding the shortest path. The depth-first strategy explores down along a branch to the end, and then traces back to the previous branch. It is suitable for finding all possible solutions. i,j represents the shortest distance between nodes i and j, and p and q are parameters for adjusting the walking strategy; among them, homogeneity means that two nodes belonging to the same cluster are more similar, and structural equivalence means that two nodes with the same structural role are more similar;
[0153] Step (2.2) According to the weight calculation formula, we can further obtain Λ(CI)+CD=(W⊙Q)C, where D represents the degree matrix of the hypergraph. The degree matrix is a diagonal matrix, and its diagonal elements represent the degrees of the corresponding vertices.
[0154] Among them, W represents the weight between nodes determined by the degree, and the element in the i-th row and j-th column of the matrix is expressed as
[0155]
[0156] Step (2.2.3) is further calculated to deduce the closed form of the convolution weight matrix C = (Λ + L) -1 Λ; where L = DW⊙Q;
[0157] The third step is to perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the embedded expression of the Mashup. The process is as follows:
[0158] Step (3.1) combines the convolution weight matrix with the traditional hypergraph convolutional network. Based on LightGCN, the feature transformation and activation function are discarded, the convolution operation is simplified, and the convolution operation is defined as X (l+1) =D (-1) SX (l) ;
[0159] Among them, LightGCN is a recommendation algorithm based on graph neural network. It improves efficiency and performance by simplifying the model structure. It is easy to understand and explain and is widely used. Feature transformation refers to the method of obtaining new features through certain rules or mappings of the original features. The activation function refers to a functional relationship between the output of the upper node and the input of the lower node in the multi-layer neural network. (l) and X (l+1) Represents the input and output of a single convolution, S represents the adjacency matrix, D (-1) represents the inversion of matrix D;
[0160] Step (3.2) introduces the convolution weight matrix C and performs the hypergraph convolution operation;
[0161] Among them, the single-layer convolution formula is X (l+1) =CX (l) , the convolution formula of the hypergraph convolutional network with L layers of convolution is y (L) =C…(CX (0) );
[0162] in, represents the input matrix composed of the embedding matrices of the hypergraph vertices. Since the present invention adopts a multi-channel hypergraph convolutional network, C in the formula can be replaced by the convolution weight matrices C1, C2, C3 and C4 of the hypergraphs G1, G2, G3 and G4 to obtain the output result y1 (L) ,y2 (L) ,y3 (L) 、y4 (L) ;
[0163] Where s represents the embedding length.
[0164] Step (3.3) averages the output of each convolution to obtain the final output of each channel;
[0165] Among them, y n The calculation formula is
[0166] Step (3.4) aggregates the output of each channel to obtain the embedded expression Y of the Mashup m ;
[0167] The aggregation between channels introduces the channel attention module to realize channel attention. The channel attention module is a commonly used attention mechanism module in deep learning. It can improve the performance of the model by strengthening the channel features of the input feature map. Its core lies in its ability to learn the relationship between different channels and dynamically adjust the weights of different channels.
[0168] Step 4: Use Bert to encode the API according to its description document to obtain the embedded expression Y of the API a ;
[0169] Where j represents the API number. BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language model based on the Transformer architecture that can simultaneously consider contextual information. It is pre-trained through masked language models and next sentence prediction, and is suitable for a variety of natural language processing tasks, such as text classification and question-answering systems. BERT's bidirectional characteristics make it excellent in understanding text;
[0170] Step 5: Optimize the model based on the model recommendation results. The process is as follows:
[0171] Step (5.1) scores the matching degree between the embedded expression of the Mashup and the embedded expression of the API, and obtains the top K matching APIs;
[0172] Among them, Mashup m i with API a j Matching score between By calculating Y m and Y a The inner product between them is obtained;
[0173] Step (5.2) calculates the loss of the model and adjusts the parameters of the model;
[0174] Among them, BPR loss is used to represent the loss of the recommendation model. BPR loss is a loss function used to learn user personalized preferences in recommendation systems, which can make positive samples rank higher than negative samples. Among them, positive samples represent API samples actually called by the current Mashup, and negative samples represent API samples that are not actually called by the current Mashup. The calculation formula of the loss function is:
[0175]
[0176] in, Represents Mashup m i with API a j Matching score, Represents Mashup m i with API a k The matching score between , log represents the logarithmic function, σ represents a learnable weight matrix, and Φ represents the model parameters;
[0177] Reference Figure 2 , showing the visualization comparison results of the embedding distance between positive and negative samples of the embedding method of the present invention (MCHCN) and the LightGCN embedding method, including the following steps:
[0178] Step 1: Crawl Mashup service data from the ProgrammableWeb platform, conduct experiments, and randomly select 3 Mashup cases from the service data set. For each Mashup, select all positive samples and 5 randomly selected negative samples with the same or similar labels as data for visualization.
[0179] Step 2: Use the t-SNE algorithm to reduce the high-dimensional embedding of the Mashup and API obtained by the LightGCN model and the model of the present invention to a low-dimensional space for visualization.
[0180] Among them, t-SNE is an algorithm for dimensionality reduction and visualization of high-dimensional data, which can effectively maintain the local structure between data points.
[0181] Step 3: Evaluate the calculation results;
[0182] Compare Figure 2 It can be found that, in general, for any mashup, the embedding learned by the model of the present invention has a better ability to distinguish positive samples from negative samples than the LightGCN model. For example, Figure 2It is shown in the figure that the average distance between the positive sample and the Mashup obtained by the embedding learned by the model of the present invention is much closer than the average distance between the negative sample and the Mashup, and the ability to distinguish between positive and negative samples has been greatly improved compared with LightGCN. This result shows that the method of the present invention has an advantage in distinguishing positive and negative samples, because it effectively utilizes the characteristics of the unique labels and call information of the service data through the motif to extract more information, and corrects the model error and enhances the representation of service features through contrastive learning.
[0183] The contents described in the embodiments of this specification are merely enumerations of implementation forms of the inventive concept and are for illustrative purposes only. The protection scope of the present invention should not be considered to be limited to the specific forms described in this embodiment, and the protection scope of the present invention also extends to equivalent technical means that can be thought of by ordinary technicians in this field based on the inventive concept.
Claims
1. A Web API recommendation method based on a multi-channel hypergraph convolutional network, characterized in that: The method comprises the following steps: The first step is to extract the service hypergraph based on the service motif. The process is as follows: Step (1.1) crawl Mashup service information from relevant API websites; Step (1.2) analyzes the crawled Mashup service set and selects meta-information that is helpful to improve the accuracy of service recommendation and is rich in content; Step (1.3) summarizes four types of motifs: co-correlation motifs, multiple strong correlation motifs, single relationship motifs, and complex relationship motifs; Step (1.4) constructs a multi-channel hypergraph based on the motif proposed in step (1.3); The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph through the hybrid random walk algorithm. The process is as follows: Step (2.1) proposes a hybrid random walk algorithm based on the combination of partial absorption random walk and biased random walk to calculate the convolution weight matrix C on the hypergraph; Step (2.2) is further obtained according to the weight calculation formula: Λ(CI)+CD=(W⊙Q)C, where Λ is a regularized matrix with all values greater than 0, D represents the degree matrix of the hypergraph, which is a diagonal matrix whose diagonal elements represent the degrees of the corresponding vertices; W represents the weights between nodes determined by the degrees, and Q is a parameter matrix used to adjust the transition probability in the biased random walk; Step (2.3) is further calculated to deduce the closed form of the convolution weight matrix C = (Λ + L) -1 Λ; where L = DW⊙Q; Step 3: Perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the embedded expression of the Mashup; Step 4: Use Bert to encode the API according to its description document to obtain the embedded expression Y of the API a ; Step 5: Optimize the model based on the model recommendation results.
2. The Web API recommendation method based on a multi-channel hypergraph convolutional network as claimed in claim 1, characterized in that: In the step (1.2), the retained meta-information includes Mashup, API, the calling relationship between Mashup and API, and the tags carried by Mashup; The Mashup set is defined as M = {m1,m2,…,m N }, where N is the total number of Mashups in the set, Mashupm i The API set called is A i ={a i,1 ,a i,2 ,a i,3 ,…,a i,k }, k is Mashup m i The total number of APIs called. The set of APIs called by all Mashups is Where ∪ means finding the union of all sets; Mashup-API call relationships are stored in a 0-1 matrix In which, each pair of Mashup m and API a, t m,a =1 indicates that Mashup m has a calling relationship with API a, t m,a =0 means there is no calling relationship between Mashup m and API a; Among them, the label represents part of the function or attribute of the Mashup. The label information contains the collaborative information between the Mashup and the API. Therefore, the feature mining process of the API and Mashup not only uses the call information but also the label information. To represent the relationship between labels and Mashup, each pair of Mashup m and label ta involved, R m,ta =1 means that Mashup m and tag ta have a carrying relationship, R m,ta =0 means that there is no carrying relationship between Mashup m and tag ta.
3. The Web API recommendation method based on a multi-channel hypergraph convolutional network according to claim 1 or 2, characterized in that: In the step (1.3), the motif represents a connection pattern that appears repeatedly in the network and is significantly higher in number than other complex networks. This connection pattern often holds key information about the network. A large number of studies have proven that motifs have a substantial ability to bridge the gap between micro- and macro-structural information. The descriptions of the four motifs are as follows: Co-associated motif: In the Mashup call scenario, there are two Mashups that carry the same label, which is called a same-label relationship. In the service data, there are Mashups that have the same label relationship between each other and form a ternary closure structure, which is called a co-associated motif. The ternary closure is a concept in social network theory, which refers to a property of a triple consisting of three nodes A, B, and C, that is, there is a strong connection between A and B, A and C, and B and C. Multiple strong correlation motifs: Labels are diverse and artificially defined, which causes uncertainty in the labels carried by Mashups. A pair of Mashups carrying two or more identical labels is defined as a strong correlation, and a closed-loop structure with strong correlations between multiple Mashups is defined as a multiple strong correlation motif. Single relationship motif: The calling relationship between Mashup and API presents the functional characteristics of Mashup. Two Mashups that call the same API have functional similarities. The motif of two Mashups calling the same API is defined as a single relationship motif. Composite relationship motif: Mashups call the same API and carry the same label. In order to use this feature to explore the relationship between mashups, mashups that call the same API and have the same label relationship are defined as composite relationship motifs.
4. The Web API recommendation method based on a multi-channel hypergraph convolutional network as claimed in claim 3, characterized in that: The process of step (1.4) is as follows: Step (1.4.1) constructs the hypergraph G1 based on the "co-correlation motifs", the process is as follows; Step (1.4.1.1) Calculate the relationship matrix R based on the Mashup-label relationship matrix Perform step (1.4.1.2); in, Indicates the number of identical labels between Mashups, where " indicates the transpose of the matrix; Step (1.4.1.2) construct the upper triangular matrix R * , used to indicate whether the mashups carry the same tags, and then proceed to step (1.4.1.3); Among them, R * By matrix Take the upper right corner of the diagonal and set all numbers greater than 0 to 1; Step (1.4.1.3) calculates the adjacency matrix of the hypergraph G1; The adjacency matrix is a matrix that represents the adjacent relationship between vertices in the hypergraph. The calculation formula of the adjacency matrix S1 of the hypergraph G1 is S1=(R * R * )⊙R * , where ⊙ represents the Hadamard product of the left and right matrices; Step (1.4.2) constructs the hypergraph G2 based on "multiple strongly correlated motifs", the process is as follows; Step (1.4.2.1) constructs a matrix R′ to represent whether the mashups carry two or more identical tags, and proceeds to step (1.4.2.2); Among them, the matrix R′ is obtained by taking the matrix The upper right diagonal is constructed by setting all numbers greater than 2 to 1 and the rest to 0; Step (1.4.2.2) calculates the adjacency matrix of the hypergraph G2; Step (1.4.3) constructs the hypergraph G3 based on the "single relation motif", the process is as follows; Step (1.4.3.1) is calculated based on the Mashup-API call relationship matrix T Perform step (1.4.3.2); in, Indicates the number of calls to the same API between Mashups; Step (1.4.3.2) is based on the matrix Calculate the matrix T * , proceed to step (1.4.3.3); Among them, the matrix T * By taking the matrix The upper right corner of the diagonal line is constructed by setting all numbers greater than 0 to 1, indicating whether the same API is called between mashups; Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3; The calculation formula of the adjacency matrix S3 of the hypergraph G3 is S3 = T * T *" ; Step (1.4.4) Based on the "composite relational motif", the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R * Find the Hadamard product, calculate the adjacency matrix of the hypergraph G4 and construct the hypergraph G4; The calculation formula of the adjacency matrix S4 of the hypergraph G4 is S4=(T * T *" )⊙R * , which means filtering out Mashup pairs that do not carry the same label.
5. The Web API recommendation method based on a multi-channel hypergraph convolutional network as claimed in claim 4, characterized in that: The process of step (1.4.2.2) is: Step (1.4.2.2.1) defines the adjacency matrix S2 to represent the adjacency matrix of the hypergraph G2; Step (1.4.2.2.2) traverses the Mashup set M, and initializes the value i to 1 to record the Mashup number, and performs steps (1.4.2.2.2.1-1.4.2.2.2.3) to calculate all values of the i-th row in S2. The process is as follows; Step (1.4.2.2.2.1) traverses the Mashup set M and initializes the value j to 1 to record the Mashup number and calculates S2 in S2 i,j The value of , the process is; Among them, S2 i,j represents the value of the i-th row and j-th column in the adjacency matrix S2; Step (1.4.2.2.2.1.1) queries the matrix R to confirm whether the number of identical tags carried by Mashup i and Mashup j is greater than 1. If so, replace S2 i,j Set to 1, otherwise set to 0 and proceed to step (1.4.2.2.2.1.2); In step (1.4.2.2.2.1.2), take j=j+1 and proceed to step (1.4.2.2.2.1.3); Step (1.4.2.2.2.1.3) determines whether j is less than or equal to N. If so, return to step (1.4.2.2.2.1.1), otherwise exit the loop; In step (1.4.2.2.2.2), let i=i+1 and proceed to step (1.4.2.2.2.3); Step (1.4.2.2.2.3) determines whether i is less than or equal to N. If so, return to step (1.4.2.2.2.1), otherwise exit the loop.
6. The Web API recommendation method based on a multi-channel hypergraph convolutional network according to claim 1 or 2, characterized in that: In (2.1), the convolution weight matrix in, represents the set of real numbers, c i,j represents the value of the i-th row and j-th column in matrix C, represents a matrix of size N×N composed of real numbers, ∈ represents the belonging relationship between elements and sets; the process is: In order to avoid the random walk from converging to a stationary distribution determined only by the degree of each node, we refer to the partial absorption random walk and assume that the random process X = {X t :t≥0} is the transition probability matrix Among them, the partially absorbing random walk is a second-order Markov chain. In each state, there is a certain probability of staying in the current state or transitioning to the next state, which is determined by the transition probability p i,j Decision, thus capturing the global semantic structure of the topology. Once the walk stops at a certain state, it will always remain in that state, that is, it is absorbed in the current state; in, Among them, d i represents the degree of vertex i, which represents the number of edges connected to the vertex in the graph, S i,j represents the value of the i-th row and j-th column in the adjacency matrix S, λ i ∈Λ,Λ=diag(λ1,λ2,…,λ N ) is a regularized matrix whose values are all greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix, and the calculation formula of Λ is Λ=δI, where I represents the unit matrix, δ represents the weight coefficient, and the absorption probability between nodes is adjusted by adjusting δ; Step (2.1.2) combines the parameter matrix Q with P to obtain the convolution weight calculation formula on the hypergraph Among them, Q is the parameter matrix used to adjust the transition probability in the biased random walk. The biased random walk combines the breadth-first and depth-first sampling strategies to adjust the transition probability. The element q in the i-th row and j-th column of the matrix Q is i,j The calculation formula is Among them, d i,j represents the shortest distance between nodes i and j, p and q are parameters for adjusting the walking strategy, homogeneity means that two nodes belonging to the same cluster are more similar, and structural equivalence means that two nodes with the same structural role are more similar.
7. The Web API recommendation method based on a multi-channel hypergraph convolutional network according to claim 1 or 2, characterized in that: The process of step three is as follows: Step (3.1) combines the convolution weight matrix with the traditional hypergraph convolutional network. Based on LightGCN, the feature transformation and activation function are discarded, the convolution operation is simplified, and the convolution operation is defined as X (l+1) =D (-1) SX (l) ; Among them, LightGCN is a recommendation algorithm based on graph neural network, X (l) and X (l+1) Represents the input and output of a single convolution, S represents the adjacency matrix, D (-1) represents the inversion of matrix D; Step (3.2) introduces the convolution weight matrix C and performs the hypergraph convolution operation; Among them, the single-layer convolution formula is X (l+1) =CX (l) , the convolution formula of the hypergraph convolutional network with L layers of convolution is y (L) =C…(CX (0) ); in, represents the input matrix composed of the embedding matrices of the hypergraph vertices. Since a multi-channel hypergraph convolutional network is used, C in the formula is replaced by the convolution weight matrices C1, C2, C3 and C4 of the hypergraphs G1, G2, G3 and G4, and the output result y1 is obtained (L) ,y2 (L) ,y3 (L) ,y4 (L) ; Where s represents the embedding length; Step (3.3) averages the output of each convolution to obtain the final output of each channel; Among them, y n The calculation formula is Step (3.4) aggregates the output of each channel to obtain the embedded expression Y of the Mashup m .
8. The Web API recommendation method based on a multi-channel hypergraph convolutional network according to claim 1 or 2, characterized in that: The process of step five is as follows: Step (5.1) scores the matching degree between the embedded expressions of Mashup and API, and obtains the top K matching APIs; i with API a j Match score between By calculating Y m and Y a The inner product between them is obtained; Step (5.2) calculates the loss of the model and adjusts the parameters of the model; BPR loss is used to represent the loss of the recommendation model, positive samples represent API samples actually called by the current Mashup, and negative samples represent API samples not actually called by the current Mashup. The loss function is calculated as in, Represents Mashup m i with API a j Matching score, Represents Mashup m i with API a k where log represents the logarithmic function, σ represents a learnable weight matrix, and Φ represents the model parameters.
Citation Information
Patent Citations
SaaS-oriented Web Api diversity recommendation method fused with restart random walk algorithm
CN115599980A
Cloud-oriented Mashup service clustering method based on hypergraph multistage clustering
CN115620040A
Third-party API recommendation method based on hypergraph neural network
CN115718841A
Multi-modal hypergraph-based click prediction
US20240380822A1