A network API recommendation method for developers
By constructing the developer API interaction matrix and using factor decomposition machines, multi-head attention mechanisms and deep neural networks to extract feature cross-relationships, the problem of low API recommendation performance in the existing technology is solved, and more accurate and efficient API recommendations are achieved.
Patent Information
- Application Number
- CN202210336751.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-31
- Publication Date
- 2025-03-11
- Estimated Expiration
- 2042-03-31
AI Technical Summary
The prior art cannot fully extract the implicit information in user behavior and API description data, resulting in low API recommendation performance.
By obtaining network API description information and the interaction history between developers and APIs, extracting the co-occurrence relationship between APIs, constructing the developer API interaction matrix, and extracting low-order and high-order feature cross-relationships through factor decomposition machines and multi-head attention mechanisms, and combining them with deep neural networks for recommendations.
It improves the accuracy and efficiency of API recommendations, and can better capture developers' preferences for APIs, thereby optimizing API recommendation results.
Smart Images

Figure CN114676332B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of service computing and data analysis, and in particular relates to a network API (Application Programming Interface) recommendation method for developers. Background Art
[0002] With the rapid development of the Internet, the use of network APIs to quickly develop new applications has become popular. In particular, the emergence of Mashup technology allows developers to freely combine APIs according to their own wishes to develop new applications, simplifying the API reuse process and improving the efficiency of application development. As a large number of APIs are published on the Internet, many API portals and registries have emerged, such as ProgrammableWeb.com, APIs.guru, etc. As of 2021, there are more than 24,000 network APIs on the ProgrammableWeb platform, and this number is still growing rapidly. The huge number of APIs makes developers face serious information overload when looking for suitable APIs. Therefore, it is very necessary to accurately recommend APIs for creating new applications to developers. API recommendation can not only solve the problem of API information overload to a certain extent, but also inspire developers to develop new applications, thereby promoting the development of the entire API ecosystem.
[0003] Traditional collaborative filtering recommendation methods cannot fully extract implicit information from user behavior and API description data, resulting in poor recommendation performance. Summary of the invention
[0004] The purpose of the present invention is to provide a network API recommendation method for developers, so as to overcome the problem that the existing methods cannot fully extract the implicit information in the user behavior and API description data, resulting in low recommendation performance.
[0005] In order to achieve the above tasks, the present invention adopts the following technical solutions:
[0006] A network API recommendation method for developers, including:
[0007] Obtain network API description information and developer-API interaction history, and extract co-occurrence relationships between APIs;
[0008] The interaction history between developers and APIs, API description information, and co-occurrence relationships between APIs are constructed into a developer API interaction matrix and coded.
[0009] Convert the developer API interaction matrix into an embedding vector matrix of dense features;
[0010] Capturing the cross-relationship of first-order and second-order low-order features in the embedding vector matrix through a factor decomposition machine; wherein the first-order feature is the influence of each feature on the prediction score, and the second-order feature is the influence of the feature combination on the prediction score;
[0011] Based on the embedding vector matrix, a multi-head attention mechanism is used to capture the cross-relationships of different internal features according to weights, and the vectors are re-encoded according to the weights of the combinations of the relationships to obtain an integrated high-order vector representation form, which is then concatenated to obtain a high-order representation vector;
[0012] Inputting the high-order representation vector into a deep neural network model, and using the multi-layer fully connected layers of the model to capture high-order feature interaction relationships;
[0013] The obtained low-order feature cross-relationships and high-order feature cross-relationships are calculated to obtain the probability scores of developers' preference for the APIs, and recommendations are made in descending order.
[0014] Furthermore, the API description information includes API category information, API provider, API popularity and developer attention relationship to the API; the developer attention relationship to the API is used as an interaction relationship to obtain the interaction history record between the developer and the API; the information of the Mashup application is obtained, and the co-occurrence relationship of the API is extracted therefrom; if a Mashup application calls two APIs at the same time, it is said that there is a co-occurrence relationship between the two APIs.
[0015] Furthermore, the features in the developer API interaction matrix include developer name, concerned API, API category information, API category information, API provider, API co-occurrence relationship and API popularity; these features are one-hot encoded; API popularity is a continuous value and is directly retained without processing.
[0016] Furthermore, the step of converting the developer API interaction matrix into an embedding vector matrix of dense features includes:
[0017] An attribute embedding vector e in the embedding vector matrix ik The calculation formula is as follows:
[0018] e ik =x i E k
[0019] Among them, x i={Feature1,Feature2,…,FeatureK} is a record in the developer API interaction matrix, and Feature1,Feature2,…,FeatureK refers to K features in the developer API interaction matrix; E k ∈R H ×embedding size is a set of parameter vectors in the parameter matrix of the embedding layer, R H×embedding size is the parameter matrix of the embedding layer, H represents the total number of feature categories, and embedding size is the configurable embedding vector dimension.
[0020] Furthermore, the factor decomposition machine captures the first-order and second-order low-order feature cross-relationships in the embedding vector matrix, which is expressed as:
[0021]
[0022] In the above formula, y FM is the prediction score obtained by the factorization machine part, w0 is the global bias, and w i is the weight term of the first-order feature; d is the dimension after encoding, e im and e in are different input features, i.e., feature embedding vectors e ik , K represents the number of features; e im and e in The associated feature weights between them are determined by their corresponding latent vectors V i and V j The squared Euclidean distance d 2 (V i +V j ,V j )express; represents the first-order feature cross relationship, Represents the second-order feature cross relationship.
[0023] Furthermore, based on the embedding vector matrix, a multi-head attention mechanism is used to capture the cross-relationships of different internal features according to weights, and the vector is re-encoded according to the weights of each relationship to obtain an integrated high-order vector representation form, and the high-order representation vector is obtained after splicing, including:
[0024]
[0025]
[0026]
[0027]
[0028] Among them, K represents the number of features contained in a developer API interaction matrix record, f represents the feature, represents the embedding vector of the k1k2th feature of the i-th record, Represents the attention weight score of the two features k1k2, is the conversion matrix in the attention mechanism, <·> represents the dot product, is the transformation matrix of attention weights, represents the weight score of the kth feature and the jth feature, e ij is an attribute embedding vector e in the embedding vector matrix ik ; is the feature value of the kth feature obtained by the hth attention head. Combined to get is the representation vector calculated by a single attention head, h = 1, 2, ... H; concatenate the vectors obtained by H attention heads to obtain a high-order representation vector Represents a concatenation operation.
[0029] Furthermore, the obtained low-order feature cross-relationship and high-order feature cross-relationship are calculated to obtain the probability score of the developer's preference for the API, and the recommendation is made in descending order, including:
[0030] The predicted score y output after factorization machine processing FM The predicted score y from the deep neural network model Deep Connect them to get the output data
[0031]
[0032] Among them, sigmoid is the activation function,
[0033] Will Recommendations are made in descending order to predict developers' preferences for APIs and recommend APIs to them.
[0034] A terminal device includes a processor, a memory, and a computer program stored in the memory; when the processor executes the computer program, the steps of the network API recommendation method for developers are implemented.
[0035] A computer-readable storage medium stores a computer program; when the computer program is executed by a processor, the steps of the network API recommendation method for developers are implemented.
[0036] Compared with the prior art, the present invention has the following technical features:
[0037] 1. Not only the description information of the API is used, but also the co-occurrence relationship of the API and the quality attributes of the API are used to solve the problem of poor recommendation effect of existing technologies.
[0038] 2. Improve the deep factorization machine and introduce the self-attention mechanism to form a self-attention representation learning module to overcome the problem of insufficient representation ability of existing technologies.
[0039] 3. Combine the improved factorization machine with the deep neural network. The factorization machine module and the deep neural network module can be trained together. The factorization machine model is responsible for extracting the correlation features between low-order features and the sequence features of user behavior, and the deep neural network is responsible for extracting higher-order features, so as to make recommendations more accurately and efficiently. As an end-to-end model, compared with other models, it does not require redundant feature engineering operations, is more convenient, and has higher training efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 is a flow chart of a network API recommendation method for developers of the present invention;
[0041] Figure 2 It is an example diagram of API information used in the network API recommendation method for developers of the present invention;
[0042] Figure 3 It is a model structure diagram of the network API recommendation method for developers of the present invention. DETAILED DESCRIPTION
[0043] The present invention is further described below in conjunction with embodiments. It is necessary to point out that the following embodiments are only used to further illustrate the present invention and cannot be understood as limiting the scope of protection of the present invention. Some non-essential improvements and adjustments made by technical personnel in this field based on the above invention content still fall within the scope of protection of the present invention.
[0044] See also Figure 1 The present invention provides a network API recommendation method for developers, comprising the following steps:
[0045] Step 1: Obtain network API description information and the interaction history between developers and APIs, and extract the co-occurrence relationship between APIs.
[0046] In a specific application example of the present invention, API description information is obtained from a network API portal (Programmableweb.com), and the obtained API description information includes API category information, API providers, API popularity, and developers' attention to the API; this example uses the developer's attention to the API on ProgrammableWeb as the interaction relationship, and the record of the interaction relationship is the interaction history record. At the same time, the information of the Mashup application is obtained from ProgrammableWeb, and the co-occurrence relationship of the API is extracted therefrom. Mashup is a network application developed based on API. If a Mashup calls two APIs at the same time, it is said that there is a co-occurrence relationship between the two APIs. Examples of the above information are as follows: Figure 2 As shown in the figure, the mashup application FollowerFly calls both the Reddit API and the Twitter API, so it is believed that there is a co-occurrence relationship between the Reddit API and the Twitter API.
[0047] Step 2: Construct the interaction history between developers and APIs, API description information, and the co-occurrence relationship between APIs into a developer API interaction matrix and encode it.
[0048] One-hot encoding is performed on the features in the developer API interaction matrix, including developer name, APIs of interest, API category information, API category information, API providers, API co-occurrence relationships, and API popularity. One-hot encoding means using a vector of length N to represent an entity, where the nth bit in the vector is 1 and the other bits are 0 to represent the nth entity. API popularity is a continuous value and can be retained without processing.
[0049] In one example of the present invention, an example of a developer API interaction matrix is as follows:
[0050]
[0051] Step 3: Convert the developer API interaction matrix into an embedding vector matrix of dense features.
[0052] A specific application example of the present invention is as follows: Figure 3 As shown, the embedding layer in deep learning is used to convert the developer API interaction matrix into a continuous and dense embedding vector matrix in the feature space; wherein an attribute embedding vector e in the embedding vector matrix ik The calculation formula is as follows:
[0053] e ik =x i E k
[0054] Among them, x i ={Feature1, Feature2, …, FeatureK} is a record in the developer API interaction matrix. Feature1, Feature2, …, FeatureK refer to K features in the developer API interaction matrix, including the developer name, the API of interest, etc.; E k ∈R H×embedding size is a set of parameter vectors in the parameter matrix of the embedding layer, R H ×embedding size is the parameter matrix of the embedding layer, H represents the total number of feature categories, and embedding size is the configurable embedding vector dimension.
[0055] Step 4, capturing the first-order and second-order low-order feature cross-relationships in the embedding vector matrix through a factor decomposition machine; wherein the first-order feature refers to the influence of each feature on the prediction score considered separately, and the second-order feature refers to the influence of the feature combination on the prediction score.
[0056] A specific application example of the present invention is as follows: Figure 3 As shown, the output of the factorization machine consists of two parts, one additional unit and multiple inner product units, y FM is the prediction score obtained by the factorization machine part:
[0057]
[0058] In the above formula, w0 is the global bias, w i is the weight term of the first-order feature; d is the dimension after One-Hot encoding, e im and e in are different input features, that is, the feature embedding vector e obtained in step 3 ik (k=m,n); K represents the number of features. im and e in The associated feature weights between them are determined by their corresponding latent vectors V i and V j The squared Euclidean distance d 2 (V i +V j ,V j )express; represents the first-order feature cross relationship, Represents the second-order feature cross relationship.
[0059] Step 5: Based on the embedding vector matrix, a multi-head attention mechanism is used to capture the cross-relationships of different internal features according to the weights, and the vectors are re-encoded according to the weights of each relationship to obtain an integrated high-order vector representation. After concatenation, we get a high-order representation vector
[0060] A specific application example of the present invention is as follows: Figure 3 The calculation formula is as follows:
[0061]
[0062]
[0063]
[0064]
[0065] Among them, K represents the number of features contained in a developer API interaction matrix record, f represents the feature, represents the embedding vector of the k1k2th feature of the i-th record, Represents the attention weight score of the two features k1k2, is the conversion matrix in the attention mechanism, <·> represents the dot product, is the transformation matrix of attention weights, represents the weight score of the kth feature and the jth feature, e ij is an attribute embedding vector in the embedding vector matrix, i.e., e in step 3 ik ; is the feature value of the kth feature obtained by the hth attention head. Combined to get is the representation vector calculated by a single attention head, h = 1, 2, ... H; Formula 4 represents the concatenation of the vectors obtained by H attention heads to obtain a high-order representation vector Represents a concatenation operation.
[0066] The purpose of this step is to improve the deep factorization machine and introduce the self-attention mechanism to overcome the problem of insufficient representation ability of the existing technology; Vector input to the deep neural network model.
[0067] Step 6: transform the high-order characterization vector Input the deep neural network model DNN, and use the model's multi-layer fully connected layers to capture high-order feature interactions.
[0068] A specific application example of the present invention is as follows: Figure 3 As shown, the steps are as follows:
[0069]
[0070] The feedforward process of the neural network model is as follows:
[0071] a (l+1) =σ(W (l) a (l) +b (l) )
[0072] Among them, a (l) represents the output of the lth layer of the neural network model, Represents a high-order representation vector Each embedding vector in, l is the layer depth of the neural network model, σ is the activation function, a (l) ,W (l) , b (l) are the output, weight and bias of the lth layer respectively, and H is the number of layers of the deep neural network. Then the feature vector is obtained, and finally it is sent to the sigmoid function σ for prediction to get y Deep Prediction scores obtained for the deep neural network model:
[0073] y Deep =σ(W |H|+1 ·a |H| +b |H|+1 )
[0074] In the above formula, H represents the number of layers of the neural network model, W |H|+1 、a |H| 、b |H|+1 Represents weights, outputs, and biases.
[0075] Step 7: Calculate the obtained low-order feature cross-relationship and high-order feature cross-relationship to obtain the probability score of the developer's preference for the API, and make recommendations in descending order.
[0076] According to the formula, the predicted score y output after the factorization machine processing described in step 4 is FM The predicted score y of the deep neural network model described in step 6 Deep Connect them to get the output data
[0077]
[0078] sigmoid is the Sigmoid activation function,
[0079] Will Recommendations are made in descending order to predict developers' preferences for APIs and recommend APIs to them.
[0080] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A network API recommendation method for developers, characterized in that: include: Obtain network API description information and developer-API interaction history, and extract co-occurrence relationships between APIs; The interaction history between developers and APIs, API description information, and co-occurrence relationships between APIs are constructed into a developer API interaction matrix and coded. Convert the developer API interaction matrix into an embedding vector matrix of dense features; Capturing the cross-relationship of first-order and second-order low-order features in the embedding vector matrix through a factor decomposition machine; wherein the first-order feature is the influence of each feature on the prediction score, and the second-order feature is the influence of the feature combination on the prediction score; Based on the embedding vector matrix, a multi-head attention mechanism is used to capture the cross-relationships of different internal features according to weights, and the vectors are re-encoded according to the weights of the combinations of the relationships to obtain an integrated high-order vector representation form, which is then concatenated to obtain a high-order representation vector; Inputting the high-order representation vector into a deep neural network model, and using the multi-layer fully connected layers of the model to capture high-order feature interaction relationships; The obtained low-order feature cross-relationships and high-order feature cross-relationships are calculated to obtain the probability scores of developers' preference for the APIs, and recommendations are made in descending order.
2. The method for recommending a network API for developers according to claim 1, characterized in that: The API description information includes API category information, API provider, API popularity and developer attention relationship to the API; the developer attention relationship to the API is used as an interaction relationship to obtain the interaction history record between the developer and the API; the information of the Mashup application is obtained, and the co-occurrence relationship of the API is extracted from it; if a Mashup application calls two APIs at the same time, it is said that there is a co-occurrence relationship between the two APIs.
3. The network API recommendation method for developers according to claim 1, characterized in that: The features in the developer API interaction matrix include developer name, concerned API, API category information, API category information, API provider, API co-occurrence relationship and API popularity; these features are one-hot encoded; API popularity is a continuous value and is retained without any processing.
4. The method for recommending a network API for developers according to claim 1, characterized in that: The step of converting the developer API interaction matrix into an embedding vector matrix of dense features includes: An attribute embedding vector e in the embedding vector matrix ik The calculation formula is as follows: And ik =x i AND k Among them, x i ={Feature1,Feature2,…,FeatureK} is a record in the developer API interaction matrix, and Feature1,Feature2,…,FeatureK refers to K features in the developer API interaction matrix; E k ∈R H ×embedding size is a set of parameter vectors in the parameter matrix of the embedding layer, R H×embedding size is the parameter matrix of the embedding layer, H represents the total number of feature categories, and embedding size is the configurable embedding vector dimension.
5. The method for recommending network APIs for developers according to claim 1, characterized in that: The factor decomposition machine captures the first-order and second-order low-order feature cross-relationships in the embedding vector matrix, which is expressed as: In the above formula, y FM is the prediction score obtained by the factorization machine part, w0 is the global bias, and w i is the weight term of the first-order feature; d is the dimension after encoding, e im and e in are different input features, i.e., feature embedding vectors e ik , K represents the number of features; e im and e in The associated feature weights between them are determined by their corresponding latent vectors V i and V j The squared Euclidean distance d 2 (V i +V j ,V j )express; represents the first-order feature cross relationship, Represents the second-order feature cross relationship.
6. The method for recommending network APIs for developers according to claim 1, characterized in that: Based on the embedding vector matrix, a multi-head attention mechanism is used to capture the cross-relationships of different internal features according to weights, and the vectors are re-encoded according to the weights of each relationship to obtain an integrated high-order vector representation form. After splicing, a high-order representation vector is obtained, including: Among them, K represents the number of features contained in a developer API interaction matrix record, f represents the feature, represents the embedding vector of the k1k2th feature of the i-th record, Represents the attention weight score of the two features k1k2, is the conversion matrix in the attention mechanism, <·> represents the dot product, is the transformation matrix of attention weights, represents the weight score of the kth feature and the jth feature, e ij is an attribute embedding vector e in the embedding vector matrix ik ; is the feature value of the kth feature obtained by the hth attention head. Combined to get is the representation vector calculated by a single attention head, h = 1, 2, ... H; concatenate the vectors obtained by H attention heads to obtain a high-order representation vector Represents a concatenation operation.
7. The method for recommending network APIs for developers according to claim 1, characterized in that: The obtained low-order feature cross-relationship and high-order feature cross-relationship are calculated to obtain the probability score of the developer's preference for the API, and the recommendation is made in descending order, including: The predicted score y output after factorization machine processing FM The predicted score y from the deep neural network model Deep Connect them to get the output data Among them, sigmoid is the activation function, Will Recommendations are made in descending order to predict developers' preferences for APIs and recommend APIs to them.
8. A terminal device comprising a processor, a memory and a computer program stored in the memory; characterized in that: When the processor executes the computer program, the steps of the network API recommendation method for developers according to any one of claims 1 to 7 are implemented.
9. A computer-readable storage medium, wherein a computer program is stored in the medium; characterized in that: When the computer program is executed by a processor, the steps of the network API recommendation method for developers according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Personalized recommendation method based on improved factorization machine
CN110727855A
Click rate prediction method based on dynamic depth attention model
CN113010774A