Web api recommendation method based on multi-channel hypergraph convolution network
By optimizing the convolution weight matrix using a multi-channel hypergraph convolutional network and a hybrid random walk algorithm, and combining it with the BERT model, the problems of noise interference and data sparsity in Web API recommendations are solved, achieving more accurate service recommendations.
Patent Information
- Application Number
- CN202411681845.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-22
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-11-22
AI Technical Summary
Existing Web API recommendation methods suffer from noise interference and data sparsity when dealing with complex service data tag carrying and calling relationships, resulting in low recommendation accuracy.
We employ a method based on a multi-channel hypergraph convolutional network. By extracting service motifs to construct a hypergraph structure, we optimize the convolutional weight matrix using a hybrid random walk algorithm and combine it with the BERT model for API recommendation, thereby reducing noise and improving recommendation accuracy.
It effectively extracts complex high-order relationships between services, deeply explores high-order associations between Mashups and APIs, solves the data sparsity problem, and improves the robustness and accuracy of the recommendation system.
Smart Images

Figure CN119760217B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the service recommendation scenario field under Mashup development, and specifically relates to a Web API recommendation method based on a multi-channel hypergraph convolutional network. Background Technology
[0002] With the development of Service-Oriented Computing (SOC) and cloud computing, Web services have become an important carrier for IT resource delivery. SOC aims to use services as fundamental building blocks to create fast, low-cost, secure, and reliable applications. Services not only simplify software development and maintenance but also provide a solid foundation for cross-platform and cross-system integration.
[0003] In recent years, an increasing number of developers have benefited from the reuse of web services, typically in the form of Web APIs. A Web API is an application programming interface that allows web applications to access and implement storage services, messaging services, computing services, and other functionalities. For example, tech giants like Google and Microsoft are making their software and data resources publicly available as web services through Web APIs, thereby attracting a wider internet user base.
[0004] With the booming development of the Web API economy, numerous shared Web API repositories have emerged in the market, among which ProgrammableWeb is one of the largest. Specifically, statistics as of May 2021 show that there are at least 24,000 publicly accessible Web APIs across more than 400 categories of services registered and published on ProgrammableWeb. More and more developers are benefiting from the reuse of Web services, leading to the emergence of Mashup technology, which uses Web APIs as reusable components to create new products. This phenomenon clearly signifies the arrival of a new era of leveraging big data to drive application development.
[0005] Numerous Web API recommendation methods have emerged. Current research employs traditional collaborative filtering or its extended models, utilizing service collaboration information or auxiliary information from the services themselves for service recommendation. Ren et al. constructed the service composition problem as a Markov decision process, incorporating service-carrying information. This method significantly improves adaptability to the uncertain behavior of services in dynamic environments and addresses user QoS constraints. Other methods use machine learning to model Mashup services and Web APIs for recommendation. Wu et al. not only used Convolutional Neural Networks (CNNs) as the basic component for feature extraction from service description documents but also introduced additional feature interaction components to characterize the interaction information between the Mashup and the API. Sang et al. considered contextual information, incorporating it into the interaction data to alleviate data sparsity and employed adversarial training to enhance the model's robustness.
[0006] In recent years, Graph Neural Networks (GNNs) have achieved great success in many fields. Benefiting from their outstanding capabilities in modeling relational data, GNN-based models have also demonstrated remarkable potential in the service recommendation system domain. Hypergraphs extend the concept of edges in traditional graphs, allowing edges to connect more than two nodes. This provides an intuitive and natural framework for modeling complex high-order relationships between services and enables the efficient extraction of high-order relationships on service hypergraphs through node-edge transformations. Summary of the Invention
[0007] To overcome the shortcomings of existing technologies and address the complex relationships between service data tags and invocations, this invention proposes a Web API recommendation method based on a multi-channel hypergraph convolutional network. First, a hypergraph structure is extracted from services using a motif to study the complex relationships between service data. Then, to reduce noise introduction, a convolution weight matrix guided by a hybrid random walk is used in the hypergraph convolution. Finally, based on the obtained weight matrix, convolution is performed on the constructed hypergraph. The convolution results from different channels are then merged to obtain the service representation vector, which is used to recommend Web APIs with high accuracy.
[0008] This invention provides the following technical solution:
[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, 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 metadata that is beneficial to improving the accuracy of service recommendations and is rich in content;
[0013] Step (1.3) summarizes four types of motifs: co-associative motifs, multiple strongly associated motifs, single relation motifs, and composite relation motifs;
[0014] Step (1.4) Construct a multi-channel hypergraph based on the phantom proposed in step (1.3);
[0015] The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph using a hybrid random walk algorithm.
[0016] Random walk is a mathematical statistical model consisting of a series of trajectories, representing a stochastic process. In random walk, each move is based on random factors rather than predetermined rules. After hypergraph extraction based on the motif structure, the current neighborhood partitioning is relatively coarse, and directly convolving this hypergraph can easily introduce noise. Therefore, random walk can be used to calculate a hypergraph convolution weight matrix to optimize the hypergraph convolution. The process is as follows:
[0017] Step (2.1) proposes a hybrid random walk algorithm based on combining partially absorbed random walk and biased random walk, and calculates the convolution weight matrix C on the hypergraph;
[0018] Step (2.2) Based on the weight calculation formula, we further obtain Λ(CI)+CD=(W⊙Q)C, where Λ is a regularization 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 degree of the corresponding vertex; W represents the weight between nodes determined by the degree, and Q is the parameter matrix used to adjust the transition probability in a biased random walk;
[0019] Step (2.3) further calculates and derives the closed-form of the convolution weight matrix: C = (Λ + L). -1 Λ; where L = DW⊙Q;
[0020] The third step is to perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the Mashup embedding representation.
[0021] Step 4: Using BERT, encode the API according to its description document to obtain the API's embedded representation Y. a ;
[0022] Step 5: Optimize the model based on the recommendation results.
[0023] Furthermore, in step (1.2), the retained metadata 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 set, and m is the number of Mashups. 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, and the set of APIs called by all Mashups. Where ∪ represents finding the union of all sets; the Mashup-API call relationships are stored in a 0-1 matrix. In this context, each pair of Mashup m and API a,t involved... m,a =1 indicates that Mashup m and API a have a calling relationship, t m,a =0 indicates that Mashup m and API a do not have a calling relationship;
[0025] Here, the labels represent some functions or attributes of the Mashup. The label information includes the collaboration 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 label information, using a 0-1 matrix. Let R represent the carrying relationship between a tag and a Mashup, where each pair of Mashups m and tags ta, R m,ta =1 indicates that there is a carry relationship between Mashup m and label ta, R m,ta =0 indicates that Mashup m and label ta have no carrying relationship.
[0026] Furthermore, in step (1.3), the motif represents the connection patterns that appear repeatedly in the network, and the number of these connection patterns is significantly higher than that of other complex networks. These connection patterns often contain key information about the network, and numerous studies have demonstrated that motifs have the substantial ability to bridge the gap between microscopic and macroscopic structural information.
[0027] The four types of phantoms are described below:
[0028] Shared-label motifs: In a Mashup call scenario, if two Mashups carry the same label, it is called a shared-label relationship. In service data, if Mashups have pairwise shared-label relationships and form a ternary closure structure, it is called a shared-label motif.
[0029] The triplet closure is a concept in social network theory, which refers to a property of a triplet consisting of three nodes A, B, and C, namely, that there are strong connections between A and B, A and C, and B and C.
[0030] Multiple strongly associated motifs: The diversity of tags and the artificial definition of tags cause uncertainty in the tags carried by Mashups. The relationship between a pair of Mashups carrying two or more identical tags is defined as a strong association relationship, and the structure of multiple Mashups forming a closed loop with strong association relationships with each other is defined as a multiple strongly associated motif.
[0031] Single Relationship Module: The relationship between a Mashup and its API reflects the functional characteristics of the Mashup. Two Mashups that call the same API have similar functions. A module in which two Mashups call the same API is defined as a single relationship module.
[0032] Composite relational motif: Mashups that call the same API and also carry the same label. In order to explore the relationship between Mashups, Mashups that call the same API and have the same label are defined as composite relational motifs.
[0033] Furthermore, in step (1.4), the hypergraph is a generalization of the traditional pairwise 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 set connecting multiple nodes, not just two nodes, which allows the hypergraph to better describe complex relationships and higher-order associations. Modules are used to construct a multi-channel hypergraph, where each module constitutes a hyperedge, as follows:
[0034] Step (1.4.1) involves constructing the hypergraph G1 based on the "co-associative motif," as follows:
[0035] Step (1.4.1.1) calculates the relation matrix R based on the Mashup-label carried relation matrix. Proceed to step (1.4.1.2);
[0036] in, This indicates that the Mashups carry the same number of tags. The "" indicates the transpose of the matrix.
[0037] Step (1.4.1.2) Construct the upper triangular matrix R *This is used to indicate whether Mashups carry the same tag, and to proceed to step (1.4.1.3);
[0038] Among them, R * From the matrix Take the top 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 adjacency relationships between vertices in a hypergraph. The adjacency matrix S1 of hypergraph G1 is calculated as S1 = (R... * R * )⊙R * Where ⊙ denotes the Hadamard product of the matrices on both sides;
[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 matrix R ′ This is used to indicate whether Mashups carry two or more identical tags, and to proceed to step (1.4.2.2).
[0043] Wherein, matrix R ′ To obtain the matrix The upper triangular matrix is constructed by setting all numbers greater than 2 to 1 and the rest to 0 in the upper right corner of the diagonal.
[0044] Step (1.4.2.2) calculates the adjacency matrix of the hypergraph G2;
[0045] Step (1.4.3) involves constructing the hypergraph G3 based on the "single relation motif," as follows:
[0046] Step (1.4.3.1) calculates the relation matrix T according to the Mashup-API call. Proceed to step (1.4.3.2);
[0047] in, This indicates the number of times the same API is called between Mashups;
[0048] Step (1.4.3.2) is based on the matrix. Calculate matrix T * Proceed to step (1.4.3.3);
[0049] Wherein, matrix T * By taking the matrix The top right corner of the diagonal is used to construct the structure by setting all numbers greater than 0 to 1, representing whether Mashups call the same API;
[0050] Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3;
[0051] The adjacency matrix S3 of the hypergraph G3 is calculated as S3 = T * T *" ;
[0052] Step (1.4.4) Based on the "composite relation motif", the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R. * Calculate the Hadamard product and construct the hypergraph G4 by computing the adjacency matrix of the hypergraph G4.
[0053] The adjacency matrix S4 of the hypergraph G4 is calculated as S4 = (T * T *" )⊙R * This means filtering out Mashup pairs that do not carry the same label.
[0054] Preferably, the process of step (1.4.2.2) is as follows;
[0055] Step (1.4.2.2.1) defines the adjacency matrix S2 as the adjacency matrix of the hypergraph G2;
[0056] Step (1.4.2.2.2) iterates through the Mashup set M and initializes the value i to 1 to record the Mashup number. Then, steps (1.4.2.2.2.1-1.4.2.2.2.3) are performed to calculate all values in the i-th row of S2. The process is as follows:
[0057] Step (1.4.2.2.2.1) Iterate through the Mashup set M and initialize the value j to 1 to record the Mashup number, and calculate S2 in S2. i,j The value is obtained, and the process is as follows;
[0058] Among them, S2 i,j This represents the value in the i-th row and j-th column of the adjacency matrix S2;
[0059] Step (1.4.2.2.2.1.1) queries matrix R to confirm whether the number of identical labels carried by Mashup i and Mashup j is greater than 1. If so, then 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 yes, return to step (1.4.2.2.2.1.1); otherwise, exit the loop.
[0062] In step (1.4.2.2.2.2), take 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 yes, return to step (1.4.2.2.2.1); otherwise, exit the loop.
[0064] In (2.1), the convolution weight matrix in, Let c represent the set of real numbers. i,j This represents the value in the i-th row and j-th column of matrix C. Let N represent a matrix of size N×N consisting of real numbers, where ∈ denotes the membership relationship between an element and a set; the process is as follows:
[0065] Step (2.1.1) To avoid the random walk converging to a stationary distribution determined solely by the degree of each node, the reference part absorbs the random walk. Let the random process X = {X...} t The transition probability matrix for t≥0 is:
[0066]
[0067] Partially absorbing random walks are a type of second-order Markov chain, characterized by a certain probability of remaining in the current state or transitioning to the next state at each state, determined by the transition probability p. i,j The decision is made to capture the global semantic structure of the topology. Once a walk stops at a certain state, it will remain in that state indefinitely, meaning it is absorbed into the current state.
[0068] in, Where, d i S represents the degree of vertex i, where degree represents the number of edges connecting the vertex to the graph. i,j Let λ represent the value in the i-th row and j-th column of the adjacency matrix S. i ∈Λ,Λ=diag(λ1,λ2,…,λ N Let Λ be a regularized matrix where all values are greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix, and Λ is calculated as Λ = δI. Here, I represents the identity matrix, and δ represents the weight coefficient. Adjusting δ can regulate the absorption probability between nodes.
[0069] Step (2.1.2) combines the parameter matrix Q with P to obtain the formula for calculating the convolution weights on the hypergraph.
[0070]
[0071] Here, Q is the parameter matrix used to adjust transition probabilities in a biased random walk. Biased random walks combine breadth-first and depth-first sampling strategies to adjust transition probabilities, thereby balancing homogeneity and structural equivalence. This allows for flexible searching of complex network structures. The element q in the i-th row and j-th column of matrix Q is... i,j The calculation formula is:
[0072] Breadth-first search (BFS) and depth-first search (DFS) are two common search strategies. BFS traverses the graph or tree structure level by level, visiting all adjacent nodes first, then proceeding to the next level, and is suitable for finding the shortest path. DFS explores a branch downwards to its end, then backtracks to the previous branch, and is suitable for finding all possible solutions. Where d... i,j Let represent the shortest distance between nodes i and j, and p and q be parameters for adjusting the traversal strategy. Homogeneity indicates that two nodes belonging to the same cluster are more similar, and structural equivalence indicates 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 a traditional hypergraph convolutional network. Based on LightGCN, it discards feature transformation and activation function, simplifies the convolution operation, and defines the convolution operation as X. (l+1) =D (-1) SX (l) ;
[0075] LightGCN is a recommendation algorithm based on graph neural networks. It improves efficiency and performance by simplifying the model structure, is easy to understand and interpret, and is widely used. Feature transformation refers to methods that derive new features from original features through certain rules or mappings. Activation functions refer to the functional relationship between the output of upper-layer nodes and the input of lower-layer nodes in a multi-layer neural network. (l) and X (l+1) Let S represent the input and output of a single convolution, and D represent the adjacency matrix. (-1) Indicate the inverse of matrix D;
[0076] Step (3.2) involves inputting the convolution weight matrix C and performing a hypergraph convolution operation;
[0077] The formula for a single-layer convolution is X. (l+1) =CX (l) The convolution formula for a hypergraph convolutional network with L layers of convolution is y. (L) =C…(CX)(0) );
[0078] in, Let C represent the input matrix composed of the embedding matrices of the hypergraph vertices. Since this invention uses a multi-channel hypergraph convolutional network, C in the formula can be replaced by the convolution weight matrices C1, C2, C3, and C4 of 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 outputs of each channel together to obtain the Mashup's embedding representation Y. m ;
[0083] The aggregation of channels is achieved through a channel attention module. The channel attention module is a commonly used attention mechanism in deep learning; it enhances the channel features of the input feature map, thereby improving the model's performance. Its core function lies in learning the relationships between different channels and dynamically adjusting the weights of different channels.
[0084] The process of step five is as follows:
[0085] Step (5.1) scores the matching degree between the Mashup's embedding expression and the API's embedding expression to obtain the top K matching APIs;
[0086] Among them, Mashup m i with API a j Match score By calculating Y m and Y a The inner product is obtained from the product between them;
[0087] Step (5.2) Calculate the model loss and adjust the model parameters;
[0088] Here, the BPR loss is used to represent the loss of the recommendation model. BPR loss is a loss function used to learn the personalized preferences of users in a recommendation system, which can encourage positive samples to rank higher than negative samples. 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 formula for calculating the loss function is as follows:
[0089]
[0090] in, Mashup m i with API a j Match score Mashup m i with API a k The inter-match score is represented by log, where log represents the logarithmic function, σ represents a learnable weight matrix, and Φ represents the model parameters.
[0091] The beneficial effects of this invention are that it effectively extracts complex high-order relationships between services through motifs, deeply explores high-order associations between Mashups and APIs, and effectively solves the data sparsity problem. Furthermore, by employing a hypergraph convolutional network to model multiple nodes, it can intuitively describe complex service calls and label carrying relationships. Finally, by introducing a hybrid random walk method combining partially absorbing random walks and biased random walks, the calculation process of the hypergraph convolutional weight matrix is optimized, effectively reducing the introduction of noise and improving the robustness of the recommendation system. Attached Figure Description
[0092] Figure 1 The structure of the phantom of the present invention is shown.
[0093] Figure 2 The results of the visualization comparison of the embedding distance between positive and negative samples of the embedding method of the present invention and the LightGCN embedding method are shown. Detailed Implementation
[0094] The present invention will now be described in further detail.
[0095] Reference Figure 1 A Web API recommendation method based on a multi-channel hypergraph convolutional network includes the following steps:
[0096] The first step is to extract the service hypergraph based on the service motif, 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 metadata that is beneficial to improving the accuracy of service recommendations and is rich in content;
[0099] The retained metadata includes Mashup, API, the call 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 set, and m is the number of Mashups. 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, and the set of APIs called by all Mashups. Where ∪ represents finding the union of all sets, and the Mashup-API call relationships are stored in a 0-1 matrix. In this context, each pair of Mashup m and API a,t involved... m,a =1 indicates that Mashup m and API a have a calling relationship, t m,a =0 indicates that Mashup m and API a do not have a calling relationship;
[0101] In this invention, labels represent some functions or attributes of the Mashup, and the label information includes the collaboration information between the Mashup and the API. Therefore, the feature mining process of the API and Mashup uses not only call information but also label information. This invention uses a 0-1 matrix. Let R represent the carrying relationship between a tag and a Mashup, where each pair of Mashups m and tags ta, R m,ta =1 indicates that there is a carry relationship between Mashup m and label ta, R m,ta =0 indicates that Mashup m and tag ta have no carrying relationship;
[0102] Step (1.3) summarizes four types of motifs: co-associative motifs, multiple strongly associated motifs, single relation motifs, and composite relation motifs;
[0103] Among them, motifs represent connection patterns that occur repeatedly in the network and are significantly more numerous than those in other complex networks. These connection patterns often contain key information about the network, and numerous studies have demonstrated that motifs have the substantial ability to bridge the gap between microscopic and macroscopic structural information.
[0104] The four types of phantoms are described below:
[0105] Shared-label motifs: In Mashup invocation scenarios, if two Mashups carry the same label, this invention refers to this as a shared-label relationship. In service data, if Mashups have pairwise shared-label relationships and form a ternary closure structure, this is called a shared-label motif.
[0106] The triplet closure is a concept in social network theory, which refers to a property of a triplet consisting of three nodes A, B, and C, namely, that there are strong connections between A and B, A and C, and B and C.
[0107] Multiple strongly associated motifs: The diversity of tags and the artificial definition of tags cause uncertainty in the tags carried by Mashups. This invention defines the relationship between a pair of Mashups carrying two or more identical tags as a strong association relationship, and defines the structure of multiple Mashups forming a closed loop with strong association relationships as a multiple strongly associated motif.
[0108] Single Relationship Module: The calling relationship between a Mashup and its API reflects the functional characteristics of the Mashup. Two Mashups that call the same API have similar functions. This invention defines a module in which two Mashups call the same API as a single relationship module.
[0109] Composite relational module: Mashups that call the same API and carry the same label. In order to use this feature to explore the relationship between Mashups, this invention defines Mashups that call the same API and have the same label relationship as composite relational modules.
[0110] Step (1.4) Based on the model proposed in step (1.3), proceed with steps (1.4.1-1.4.4) to construct a multi-channel hypergraph;
[0111] Hypergraph is a generalization of traditional pairwise graphs. In traditional graph theory, a graph consists of nodes (vertices) and edges, while hypergraph introduces the concept of hyperedges. A hyperedge is a set that connects multiple nodes, not just two nodes. This allows hypergraphs to better describe complex relationships and higher-order associations. This invention uses motifs to construct multi-channel hypergraphs, where each motif constitutes a hyperedge.
[0112] Step (1.4.1) constructs the hypergraph G1 based on the "co-associative motif". The process is as follows:
[0113] Step (1.4.1.1) calculates the relation matrix R based on the Mashup-label carried relation matrix. Proceed to step (1.4.1.2);
[0114] in, This indicates that the Mashups carry the same number of tags. The "" indicates the transpose of the matrix.
[0115] Step (1.4.1.2) Construct the upper triangular matrix R * This is used to indicate whether Mashups carry the same tag, and to proceed to step (1.4.1.3);
[0116] Among them, R * From the matrix Take the top 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 adjacency relationships between vertices in a hypergraph. The adjacency matrix S1 of hypergraph G1 is calculated as S1 = (R... * R * )⊙R * Where ⊙ denotes the Hadamard product of the matrices on both sides;
[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 Mashups carry two or more identical labels, and proceeds to step (1.4.2.2);
[0121] Where, matrix R′ is obtained by taking the matrix The upper triangular matrix is constructed by setting all numbers greater than 2 to 1 and the rest to 0 in the upper right corner of the diagonal.
[0122] Step (1.4.2.2) involves steps (1.4.2.2.1-1.4.2.2.2) to calculate the adjacency matrix of the hypergraph G2, and then proceeds to 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 then proceeds to step (1.4.2.2.2).
[0124] Step (1.4.2.2.2) Iterate through the Mashup set M and initialize the value i to 1 to record the Mashup number. Then perform steps (1.4.2.2.2.1-1.4.2.2.2.3) to calculate all values in the i-th row of S2.
[0125] Step (1.4.2.2.2.1) Iterate through the Mashup set M and initialize the value j to 1 to record the Mashup number, and calculate S2 in S2.i,j The value;
[0126] Among them, S2 i,j This represents the value in the i-th row and j-th column of the adjacency matrix S2;
[0127] Step (1.4.2.2.2.1.1) queries matrix R to confirm whether the number of identical labels carried by Mashup i and Mashup j is greater than 1. If so, then 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 yes, return to step (1.4.2.2.2.1.1); otherwise, exit the loop.
[0130] In step (1.4.2.2.2.2), take 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 yes, it returns to step (1.4.2.2.2.1); otherwise, it exits the loop.
[0132] Step (1.4.3) involves constructing the hypergraph G3 based on the "single relation motif". The process is as follows:
[0133] Step (1.4.3.1) calculates the relation matrix T according to the Mashup-API call. Proceed to step (1.4.3.2);
[0134] in, This indicates the number of times the same API is called between Mashups;
[0135] Step (1.4.3.2) is based on the matrix. Calculate matrix T * Proceed to step (1.4.3.3);
[0136] Wherein, matrix T * By taking the matrix The top right corner of the diagonal is used to construct the structure by setting all numbers greater than 0 to 1, representing whether Mashups call the same API;
[0137] Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3;
[0138] The adjacency matrix S3 of the hypergraph G3 is calculated as S3 = T * T * ";
[0139] Step (1.4.4) Based on the "composite relation motif", the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix R. * Calculate the Hadamard product and construct the hypergraph G4 by computing the adjacency matrix of the hypergraph G4.
[0140] The adjacency matrix S4 of the hypergraph G4 is calculated as S4 = (T * T *" )⊙R * This 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 using a hybrid random walk algorithm.
[0142] Random walk is a mathematical statistical model consisting of a series of trajectories. It is a random process in which each step is based on random factors rather than predetermined rules. After the hypergraph extraction based on the motif structure, the partitioning of the current neighborhood is relatively coarse. Directly convolving the hypergraph can easily introduce noise. A hypergraph convolution weight matrix can be calculated by using random walk to optimize the hypergraph convolution.
[0143] The second step is as follows:
[0144] Step (2.1) proposes a hybrid random walk algorithm based on combining partially absorbed 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] Wherein, the convolution weight matrix in, Let c represent the set of real numbers. i,j This represents the value in the i-th row and j-th column of matrix C. Let represent a matrix of size N×N consisting of real numbers, where ∈ indicates a membership relationship between an element and a set;
[0146] Step (2.1.1) To avoid the random walk converging to a stationary distribution determined solely by the degree of each node, the reference part absorbs the random walk. Let the random process X = {X...} t The transition probability matrix for t≥0 is:
[0147]
[0148] Partially absorbing random walks are a type of second-order Markov chain, characterized by a certain probability of remaining in the current state or transitioning to the next state at each state, determined by the transition probability p. i,j The decision is made to capture the global semantic structure of the topology. Once a walk stops at a certain state, it will remain in that state forever, that is, it will be absorbed into the current state.
[0149] in, Where, d i S represents the degree of vertex i, where degree represents the number of edges connecting the vertex to the graph. i,j Let λ represent the value in the i-th row and j-th column of the adjacency matrix S. i ∈Λ,Λ=diag(λ1,λ2,…,λ N Let be a regularized matrix where all values are greater than 0, where diag() indicates that the elements in the brackets form a diagonal matrix. The formula for calculating Λ is Λ=δI, where I represents the identity matrix and δ represents the weight coefficient. The absorption probability between nodes can be adjusted by adjusting δ. Step (2.1.2) combines the parameter matrix Q with P to obtain the formula for calculating the convolution weight on the hypergraph.
[0150]
[0151] Here, Q is the parameter matrix used to adjust transition probabilities in a biased random walk. Biased random walks combine breadth-first and depth-first sampling strategies to adjust transition probabilities, thereby balancing homogeneity and structural equivalence. This allows for flexible searching of complex network structures. The element q in the i-th row and j-th column of matrix Q is... i,j The calculation formula is:
[0152] Breadth-first search (BFS) and depth-first search (DFS) are two common search strategies. BFS traverses the graph or tree structure level by level, visiting all adjacent nodes first, then the nodes in the next level, making it suitable for finding the shortest path. DFS explores a branch downwards to its end, then backtracks to the previous branch, making it suitable for finding all possible solutions. Where d... i,j Let represent the shortest distance between nodes i and j, and p and q be parameters for adjusting the traversal strategy; where 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) Based on the weight calculation formula, we 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 degree of the corresponding vertex.
[0154] Where W represents the weight between nodes determined by degree, and the element in the i-th row and j-th column of the matrix is represented as...
[0155]
[0156] Step (2.2.3) further calculates and derives the closed-form of the convolution weight matrix: C = (Λ + L). -1 Λ; where L = DW⊙Q;
[0157] The third step involves performing convolution operations on the hypergraph and aggregating the convolution results across multiple channels to obtain the Mashup embedding representation. The process is as follows:
[0158] Step (3.1) combines the convolution weight matrix with a traditional hypergraph convolutional network. Based on LightGCN, it discards feature transformation and activation function, simplifies the convolution operation, and defines the convolution operation as X. (l+1) =D (-1) SX (l) ;
[0159] LightGCN is a recommendation algorithm based on graph neural networks. It improves efficiency and performance by simplifying the model structure, is easy to understand and interpret, and is widely used. Feature transformation refers to the method of obtaining new features from a certain original feature through certain rules or mappings. Activation function refers to a functional relationship between the output of the upper layer node and the input of the lower layer node in a multi-layer neural network. (l) and X (l+1) Let S represent the input and output of a single convolution, and D represent the adjacency matrix. (-1) Indicate the inverse of matrix D;
[0160] Step (3.2) involves inputting the convolution weight matrix C and performing a hypergraph convolution operation;
[0161] The formula for a single-layer convolution is X. (l+1) =CX (l) The convolution formula for a hypergraph convolutional network with L layers of convolution is y. (L) =C…(CX) (0) );
[0162] in, Let C represent the input matrix composed of the embedding matrices of the hypergraph vertices. Since this invention uses a multi-channel hypergraph convolutional network, C in the formula can be replaced by the convolution weight matrices C1, C2, C3, and C4 of 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 outputs of each channel together to obtain the Mashup's embedding representation Y. m ;
[0167] The aggregation of channels is achieved by introducing a channel attention module. The channel attention module is a commonly used attention mechanism in deep learning. It enhances the channel features of the input feature map, thereby improving the model's performance. Its core function lies in learning the relationships between different channels and dynamically adjusting the weights of different channels.
[0168] Step 4: Using BERT, encode the API according to its description document to obtain the API's embedded representation Y. 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, capable of simultaneously considering contextual information. It is pre-trained using a masked language model and next-sentence prediction, making it suitable for various natural language processing tasks, such as text classification and question-answering systems. BERT's bidirectional nature makes it excellent at understanding text;
[0170] Step 5: Optimize the model based on the recommendation results, as follows:
[0171] Step (5.1) scores the matching degree between the Mashup's embedding expression and the API's embedding expression to obtain the top K matching APIs;
[0172] Among them, Mashup m i with API a j Match score By calculating Y m and Y a The inner product is obtained from the product between them;
[0173] Step (5.2) Calculate the model loss and adjust the model parameters;
[0174] Here, the BPR loss is used to represent the loss of the recommendation model. BPR loss is a loss function used to learn the personalized preferences of users in a recommendation system, which can encourage positive samples to rank higher than negative samples. 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 formula for calculating the loss function is as follows:
[0175]
[0176] in, Mashup m i with API a j Match score Mashup m i with API a k The inter-match score, log represents the logarithmic function, σ represents a learnable weight matrix, and Φ represents the model parameters;
[0177] Reference Figure 2 The diagram illustrates a visual comparison of the positive and negative sample embedding distances between the MCHCN embedding method and the LightGCN embedding method of this invention, 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 dataset. 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 embeddings of the Mashup and API obtained from the LightGCN model and the model of this 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 preserve the local structure between data points.
[0181] Step 3: Evaluate the calculation results;
[0182] Compare Figure 2 It can be observed that, overall, for any Mashup, the embeddings learned by the model of this invention have a better ability to distinguish between positive and negative samples compared to the LightGCN model. For example, Figure 2The results show that the embeddings learned by the model of this invention have a significantly closer average distance between positive samples and the Mashup than between negative samples and the Mashup, demonstrating a substantial improvement in the ability to distinguish between positive and negative samples compared to LightGCN. This result indicates that the method of this invention has advantages in distinguishing between positive and negative samples because it effectively utilizes the unique features of service data's labels and invocation information through the motif to extract more information, and corrects model errors and enhances the representation of service features through contrastive learning.
[0183] The embodiments described in this specification are merely examples of implementations of the inventive concept and are for illustrative purposes only. The scope of protection of this invention should not be considered limited to the specific forms described in these embodiments; rather, it extends to equivalent technical means conceived by those skilled in the art 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 includes the following steps: The first step is to extract the service hypergraph based on the service motif, as follows: Step (1.1) Crawl Mashup service information from relevant API websites; Step (1.2) analyzes the crawled Mashup service set and selects metadata that is beneficial to improving the accuracy of service recommendations and is rich in content; Step (1.3) summarizes four types of motifs: co-associative motifs, multiple strong-associative motifs, single-relation motifs, and composite-relation motifs; the descriptions of the four types of motifs are as follows: Commonly associated modules: In a Mashup call scenario, if two Mashups carry the same label, it is called a same-label relationship. If there are pairs of Mashups with the same label in the service data and they form a ternary closure structure, it is called a commonly associated module. The triplet closure is a concept in social network theory, which refers to a property of a triplet consisting of three nodes A, B, and C, namely, that there are strong connections between A and B, A and C, and B and C. Multiple strongly associated motifs: The diversity of tags and the artificial definition of tags cause uncertainty in the tags carried by Mashups. The relationship between a pair of Mashups carrying two or more identical tags is defined as a strong association relationship, and the structure of multiple Mashups forming a closed loop with strong association relationships with each other is defined as a multiple strongly associated motif. Single Relationship Module: The relationship between a Mashup and its API reflects the functional characteristics of the Mashup. Two Mashups that call the same API have similar functions. A module in which two Mashups call the same API is defined as a single relationship module. Composite relational schema: Mashups that call the same API and also carry the same label. In order to explore the relationship between Mashups, Mashups that call the same API and have the same label are defined as composite relational schemas. Step (1.4) Construct a multi-channel hypergraph based on the phantom proposed in step (1.3); The second step is to calculate the convolution weight matrix C of the multi-channel hypergraph using a hybrid random walk algorithm, as follows: Step (2.1) proposes a hybrid random walk algorithm based on the combination of partially absorbed random walk and biased random walk, and calculates the convolution weight matrix C on the hypergraph; Step (2.2) further obtains the weight calculation formula. ,in, Let be a regularization matrix where all values are greater than 0, D represents the degree matrix of the hypergraph, which is a diagonal matrix whose diagonal elements represent the degree of the corresponding vertex; W represents the weight between nodes determined by degree, and Q is the parameter matrix used to adjust the transition probability in a biased random walk. Step (2.3) further calculates and derives the closed-form of the convolution weight matrix. ;in, ; The third step is to perform convolution operations on the hypergraph and aggregate the convolution results on multiple channels to obtain the Mashup embedding representation. Step 4: Using BERT, encode the API according to its description document to obtain the embedded representation of the API. ; Step 5: Optimize the model based on the recommendation results.
2. The Web API recommendation method based on a multi-channel hypergraph convolutional network as described in claim 1, characterized in that, In step (1.2), the retained metadata includes Mashup, API, the calling relationship between Mashup and API, and the tags carried by Mashup; Among them, the Mashup set is defined as Where N is the total number of Mashups in the set, and Mashup The set of APIs called is , For Mashup The total number of APIs called, and the set of APIs called by all Mashups. ,in This indicates finding the union of all sets; the Mashup-API call relationships are stored in a 0-1 matrix. In this context, each pair of Mashup m and API a involved, Mashup With API There is a calling relationship. Mashup With API There is no calling relationship; Here, the labels represent some functions or attributes of the Mashup. The label information includes the collaboration 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 label information, using a 0-1 matrix. This represents the carrying relationship between a tag and a Mashup, where each pair of Mashup m and tag ta is involved. Mashup There is a carrying relationship with the tag ta. Mashup There is no carrying relationship with the tag ta.
3. The Web API recommendation method based on a multi-channel hypergraph convolutional network as described in claim 1, characterized in that, The process of step (1.4) is as follows: Step (1.4.1) involves constructing the hypergraph G1 based on the "co-associative motif," as follows: Step (1.4.1.1) involves carrying the relation matrix based on the Mashup-label. calculate Proceed to step (1.4.1.2). in, This indicates that Mashups carry the same number of tags, where This indicates finding the transpose of a matrix; Step (1.4.1.2) Construct the upper triangular matrix This is used to indicate whether Mashups carry the same label, and to proceed with step (1.4.1.3). in, From the matrix Take the top right corner of the diagonal and set all numbers greater than 0 to 1; Step (1.4.1.3) Calculate the adjacency matrix of the hypergraph G1; Here, the adjacency matrix is a matrix that represents the adjacency relationship between vertices in the hypergraph. The adjacency matrix of hypergraph G1 is... The calculation formula is: ,in, This indicates the Hadamard product of the matrices on both sides. Step (1.4.2) involves constructing the hypergraph G2 based on the "multiple strongly correlated motifs". The process is as follows: Step (1.4.2.1) Constructing the matrix This is used to indicate whether Mashups carry two or more identical tags, and to proceed with step (1.4.2.2). Among them, matrix To obtain the matrix The upper triangular matrix is constructed by setting all numbers greater than 2 to 1 and the rest to 0 in the upper right corner of the diagonal. Step (1.4.2.2) Calculate the hypergraph G2 The adjacency matrix; Step (1.4.3) involves constructing the hypergraph G3 based on the "single relation motif," as follows: Step (1.4.3.1) calls the relationship matrix according to the Mashup-API. Calculated Proceed to step (1.4.3.2). in, This indicates the number of times the same API is called between Mashups; Step (1.4.3.2) is based on the matrix. Calculate the matrix Proceed to step (1.4.3.3). Among them, matrix By taking the matrix The top right corner of the diagonal is used to construct the structure by setting all numbers greater than 0 to 1, representing whether Mashups call the same API; Step (1.4.3.3) calculates the adjacency matrix of the hypergraph G3; Among them, the adjacency matrix of the hypergraph G3 S The formula for calculating 3 is: ; Step (1.4.4) Based on the "composite relation model", the adjacency matrix calculation result of the hypergraph G4 is compared with the upper triangular matrix. Calculate the Hadamard product and construct the hypergraph G4 by computing the adjacency matrix of the hypergraph G4. Among them, the adjacency matrix of the hypergraph G4 S The formula for calculating 4 is: This means filtering out Mashup pairs that do not carry the same label.
4. The Web API recommendation method based on a multi-channel hypergraph convolutional network as described in claim 3, characterized in that, The process of step (1.4.2.2) is as follows; Step (1.4.2.2.1) defines the adjacency matrix S2 to represent the hypergraph. G2 The adjacency matrix; Step (1.4.2.2.2) Iterate through the Mashup collection M and initialize its values. i 1 is used to record the Mashup number, and steps (1.4.2.2.2.1-1.4.2.2.2.3) are performed to calculate the number of the Mashup in S2. i All values of the row, the process is as follows; Step (1.4.2.2.2.1) Iterate through the Mashup set M and initialize the value j to 1 to record the Mashup number, and calculate S2 in S2. i,j The value is obtained, and the process is as follows; Among them, S2 i,j This represents the value in the i-th row and j-th column of the adjacency matrix S2; Step (1.4.2.2.2.1.1) queries matrix R to confirm whether the number of identical labels carried by Mashup i and Mashup j is greater than 1. If so, then S2 i,j Set to 1, otherwise set to 0, and proceed to step (1.4.2.2.2.1.2). Step (1.4.2.2.2.1.2) takes j = j + 1 and proceeds 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 yes, return to step (1.4.2.2.2.1.1); otherwise, exit the loop. Step (1.4.2.2.2.2) Take 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 yes, return to step (1.4.2.2.2.1); otherwise, exit the loop.
5. The Web API recommendation method based on a multi-channel hypergraph convolutional network as described in claim 1 or 2, characterized in that, In (2.1), the convolution weight matrix ,in, Represents the set of real numbers. Represents the first element in matrix C. Okay, number The value of the column, It represents a set of real numbers with a value of 1. The matrix, This represents the membership relationship between an element and a set; the process is as follows: Step (2.1.1) To avoid the random walk converging to a stationary distribution determined solely by the degree of each node, a partial absorption random walk is referenced. Let the random process... The transition probability matrix is ; Partially absorbing random walks are a type of second-order Markov chain where, in each state, there is a certain probability of remaining in the current state or transitioning to the next state, determined by the transition probability. The decision is made to capture the global semantic structure of the topology. Once a walk stops at a certain state, it will remain in that state forever, that is, it will be absorbed into the current state. in, ,in, Represents vertices The degree, S, represents the number of edges connecting vertices in the graph. i,j This represents the value in the i-th row and j-th column of the adjacency matrix S. , Let be a regularized matrix where all values are greater than 0, where This indicates that the elements in the brackets form a diagonal matrix. The calculation formula is: ,in Represents the identity matrix. This represents the weighting coefficient, which is adjusted... Adjusting the absorption probability between nodes; Step (2.1.2) will convert the parameter matrix Combined with P, we obtain the formula for calculating convolution weights on the hypergraph. ; Here, Q is the parameter matrix used to adjust the transition probabilities in a biased random walk. The biased random walk combines breadth-first and depth-first sampling strategies to adjust the transition probabilities. The Middle Line 1 Column elements The calculation formula is: ; in, Represents a node , The shortest distance between, and To adjust the parameters of the roaming 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.
6. The Web API recommendation method based on a multi-channel hypergraph convolutional network as described in claim 1 or 2, characterized in that, The process of step three is as follows: Step (3.1) combines the convolution weight matrix with a traditional hypergraph convolutional network. Based on LightGCN, it simplifies the convolution operation by discarding feature transformation and activation functions, defining the convolution operation as... LightGCN is a recommendation algorithm based on graph neural networks. and This represents the input and output of a single convolution. Represents the adjacency matrix. Representation matrix D Find the inverse; Step (3.2) Substitute the convolution weight matrix Perform hypergraph convolution operation; The formula for single-layer convolution is: ,have The convolution formula for a hypergraph convolutional network with multiple convolutional layers is: ; in, The input matrix represents the embedding matrices of the hypergraph vertices. Because a multi-channel hypergraph convolutional network is used, the formula... Replace with Hypergraph G1 , G2 , G3 and G4 Convolution weight matrix C1 , C2 , C3 and C4 Calculate the output result , , , Where s represents the embedding length; Step (3.3) averages the output of each convolution to obtain the final output of each channel; in, The calculation formula is: ; Step (3.4) aggregates the outputs of each channel to obtain the Mashup's embedded representation. .
7. The Web API recommendation method based on a multi-channel hypergraph convolutional network as described in claim 1 or 2, characterized in that, The process of step five is as follows: Step (5.1) scores the matching degree between the Mashup's embedding representation and the API's embedding representation to obtain the top... One matching API; among which, Mashup With API Match score Through calculation and The inner product is obtained from the product between them; Step (5.2) calculates the model loss and adjusts the model parameters; where 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 formula for calculating the loss function is as follows: ; in, Mashup With API Match score Mashup With API Match score Represents the logarithmic function. This represents a learnable weight matrix. Indicates 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