Third-party library recommendation method and device based on hyperbolic space
By performing multi-layer perceptron iterative calculation in hyperbolic space, combined with Lorentz measurement, the problem of poor third-party library recommendation in the existing technology is solved, and a more accurate and practical third-party library recommendation is achieved, which is suitable for Mobile application development scenario.
Patent Information
- Application Number
- CN202410725956.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-06
- Publication Date
- 2024-12-13
- Estimated Expiration
- 2044-06-06
AI Technical Summary
The existing third-party library recommendation methods lack the long-tail distribution characteristics of the relationship between mobile applications and third-party library calling, resulting in poor recommendation results and cannot meet the specific functional needs of APP developers in specific development scenarios.
Using a third-party library recommendation method based on hyperbolic space, the classification information of APP and TPL and the label text information are vector embedded through semantic models, and the node feature vectors are iteratively calculated in hyperbolic space using multi-layer perceptron and Lorentz metrics. , generate the final APP and TPL call feature information table, and then recommend third-party libraries that meet the criteria to users.
It effectively retains category and label information, solves the defects of heterogeneous node information fusion, improves the accuracy of third-party library recommendations, alleviates the problem of sparse information in long-tail distribution, and enhances the practicality and accuracy of recommendations.
Smart Images

Figure CN119128247A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of third-party library recommendation algorithms, and in particular to a third-party library recommendation method and device based on hyperbolic space. Background Art
[0002] With the development of the Internet and the popularity of mobile devices, mobile applications (APP) have attracted the attention of many developers. Faced with the fierce competition in the mobile application market, many mobile application developers choose to use third-party libraries (TPL) to shorten the development iteration cycle, improve development efficiency and product quality.
[0003] A third-party library is a code library written, open-sourced, and maintained by other developers, which can provide a wide range of functions and services. By referencing the corresponding third-party library, developers do not need to write complex code from scratch, but only need to reference it based on the requirements of functional modules and tools. However, with the increasing number and types of third-party libraries, how to filter out the third-party libraries that best suit their project needs from a large number of libraries is a problem that developers have to face. This selection process requires developers to invest a lot of time and energy. Therefore, it is very necessary to provide APP developers with a reliable and efficient method for recommending third-party libraries. Existing third-party library recommendation methods usually lack consideration of the long-tail distribution characteristics of the call relationship between mobile applications and third-party libraries, and tend to recommend popular third-party libraries with rich call data. These third-party libraries are suitable for general scenarios, but cannot meet the specific functional requirements of APP developers in specific development scenarios, resulting in poor third-party library recommendation results. Summary of the invention
[0004] In view of the technical problem that the third-party library recommendation effect in the prior art is not good, the present invention proposes a third-party library recommendation method and device based on hyperbolic space.
[0005] The technical solution adopted by the present invention is as follows:
[0006] A first aspect provides a third-party library recommendation method based on hyperbolic space, comprising:
[0007] S1: Use the semantic model to embed the APP classification information and TPL label text information into vectors, and transfer the embedded initial feature vectors to the hyperbolic space;
[0008] S2: Unify the feature vector knowledge space through multi-layer perceptron in hyperbolic space, and iteratively calculate the feature vector of APP node and the feature vector of TPL node with the help of Lorentz metric based on the strategy of positive and negative sample comparison to obtain the final node feature vector table, where the final node feature vector table contains APP and TPL call feature information;
[0009] S3: Based on the APP currently selected by the user, recommend qualified third-party libraries to the user in the final feature vector table.
[0010] In one embodiment, step S1 includes:
[0011] S11: Input the classification information of the APP and the label text information of the TPL into the pre-trained FastText model to obtain the d-dimensional APP initial feature vector and the TPL initial feature vector in the Euclidean space;
[0012] S12: The d-dimensional APP initial eigenvector and the TPL initial eigenvector are transferred from the Euclidean space to the hyperbolic space at the origin through the exponential mapping function exp0(*) of the Lorentz model, where the calculation formula of the exponential mapping is:
[0013]
[0014] e is the vector (1, 0, ..., 0), which is the origin of the hyperbolic space. Indicates APP node A i The initial eigenvectors in Euclidean space, A i The eigenvector in the hyperbolic space, c is the hyperbolic space curvature, is the Lorentz norm, calculated as:
[0015]
[0016] in, yes The time dimension of yes Component in the spatial dimension.
[0017] In one embodiment, step S2 includes:
[0018] S21: Map the APP node feature vector and the TPL node feature vector to the tangent space, use a multi-layer perceptron in the tangent space to unify the node feature knowledge space and map it back to the hyperbolic space;
[0019] S22: Construct a loss function by scoring the APP and TPL positive and negative example nodes, and optimize the model parameters through the loss function;
[0020] S23: Repeat step S22 until the maximum number of iterations is reached to obtain a node feature vector table that finally contains APP and TPL call feature information.
[0021] In one embodiment, step S21 includes:
[0022] S211: Map the APP node feature vector and the TPL node feature vector into the tangent space through a projection function, wherein the calculation formula of the projection function is:
[0023]
[0024] Where μ0 is the vector (1, 0, ..., 0), which is the origin in the hyperbolic space. is the Lorentz product, APP node A i The eigenvectors in hyperbolic space are, APP node A i Eigenvectors in tangent space;
[0025] S212: Update the node feature vector through the multi-layer perceptron MLP, where the transformation calculation formula of the l-th layer MLP is:
[0026] h (l) =ReLU(W (l) h (l-1) +b (l) )
[0027] Among them, h (l-1) is the output of the l-1th layer. For the first layer, h (0) is the feature vector of the node, W (l) and b (l) are the weight matrix and bias vector of the lth layer respectively, and ReLU is the activation function;
[0028] S213: Map the updated node feature vector back to the hyperbolic space through an exponential mapping function.
[0029] In one embodiment, step S22 includes:
[0030] S221: Calculate the score difference between the positive and negative example node pairs of APP and TPL based on the Lorentz metric, where the positive example is the APP and TPL pair with a real call relationship in the training set, and the negative example is the randomly selected APP and TPL pair with no call record. The calculation formula for the score difference between the positive and negative example node pairs of APP and TPL is:
[0031] Rating_minus=lnσ(Rating(A i , T p )-Rating(A i , T n ))
[0032] Among them, σ(·) is the Sigmoid activation function; for APP node A i and TPL node T j, the scoring formula is:
[0033]
[0034] For node A i and TPL node T j The Lorentz product of and A i Self-learned global preference features and T j Self-learned global preference features, For hyperbolic vector addition, there are two vectors x and y. The calculation formula is:
[0035]
[0036] Where c is the hyperbolic space curvature;
[0037] S222: Repeat step S221 to obtain the score differences of each APP and TPL positive and negative example node pair and add them up;
[0038] S223: Calculate the model parameter probability term according to the pseudo-hyperbolic Gaussian distribution, and the calculation formula is:
[0039]
[0040] Where d is the embedding dimension of the vector in the hyperbolic space, Θ is the set of model parameters, and λ Θ is the regularization parameter, μ0 is the origin of the hyperbolic space;
[0041] S224: Repeat steps S221-S223 to optimize the model parameters, update the node feature vectors of each APP and the node feature vectors of TPL, and obtain the final feature vector table.
[0042] In one embodiment, the optimization objective function of the model is:
[0043]
[0044] Among them, OPT is the optimization objective function, A i The eigenvectors in hyperbolic space are, T p The eigenvectors in hyperbolic space are, T n The eigenvectors in hyperbolic space are, T n The global preference feature of self-learning, c is the hyperbolic space curvature, is the Lorentz norm, Θ is the set of all parameters, λ Θis the regularization parameter, μ0 is the origin of the hyperbolic space, d is the embedding dimension of the vector in the hyperbolic space, and D s A collection of nodes.
[0045] In one embodiment, step S3 includes:
[0046] Based on the APP currently selected by the user, the topK algorithm is used to recommend the K third-party libraries with the highest current scores to the user in the final feature vector table.
[0047] Based on the same inventive concept, the second aspect of the present invention provides a third-party library recommendation device based on hyperbolic space, comprising:
[0048] The feature vector initialization module is used to perform vector embedding processing on the classification information of APP and the label text information of TPL through the semantic model, and transfer the embedded initial feature vector to the hyperbolic space;
[0049] The final feature vector table acquisition module is used to unify the feature vector knowledge space through the multi-layer perceptron in the hyperbolic space, and iteratively calculate the feature vectors of the APP node and the TPL node with the help of the Lorentz metric based on the strategy of positive and negative sample comparison to obtain the final node feature vector table, wherein the final node feature vector table contains the APP and TPL call feature information;
[0050] The third-party library recommendation module is used to recommend qualified third-party libraries to users in the final feature vector table based on the APP currently selected by the user.
[0051] Based on the same inventive concept, the third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the third-party library recommendation method based on hyperbolic space described in the first aspect.
[0052] Based on the same inventive concept, the fourth aspect of the present invention provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the third-party library recommendation method based on hyperbolic space described in the first aspect is implemented.
[0053] Compared with the prior art, the advantages and beneficial technical effects of the present invention are as follows:
[0054] The present invention encodes text information such as categories of mobile applications and third-party libraries through a semantic model, effectively retaining information such as categories and labels; effectively transfers node features from different knowledge spaces to a unified knowledge space through a multi-layer perceptron in a hyperbolic space, solving the defect of heterogeneous node information fusion in traditional third-party library recommendation methods; learns the interactive relationship between mobile applications and third-party libraries in a hyperbolic space, and then generates a score ranking based on feature representation, which alleviates the information sparsity problem of tail nodes in the long-tail distribution, improves the accuracy of recommending third-party libraries, and enhances practicality; the model combines historical data with the currently selected APP process data, and efficiently generates recommendation results for third-party libraries through a locally cacheable vector table (final node feature vector table), which is feasible in real industrial scenarios with huge data volumes. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0056] Figure 1 A flowchart of a third-party library recommendation method based on hyperbolic space provided by an embodiment of the present invention;
[0057] Figure 2 It is a schematic diagram of a third-party library recommendation model (device) based on hyperbolic space in an embodiment of the present invention. DETAILED DESCRIPTION
[0058] The present invention provides a third-party library recommendation method and device based on hyperbolic space, and the main steps include: S1: inputting mobile application (APP) category and third-party library (TPL) label text information, and obtaining the initial feature vectors of APP nodes and TPL nodes through FastText semantic model in Euclidean space; S2: using multi-layer perceptron to unify feature vector knowledge space in hyperbolic space, and then iteratively calculating node feature vectors through pairwise comparison objective function based on Lorentz metric to obtain final APP and TPL feature vector tables; S3: obtaining recommended third-party libraries in the final feature vector table through the current APP. The present invention encodes the text information of APP and TPL pairs, effectively retains the category features of APP and the label features of TPL; unifies the node feature vectors into the same knowledge space through multi-layer perceptron, overcomes the defects of heterogeneous node information fusion in traditional third-party library recommendation methods; learns long-tail distribution data features in hyperbolic space, more accurately captures the complex interactive relationship between APP and TPL, and improves the accuracy of third-party library recommendation.
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] Embodiment 1
[0061] The present invention discloses a third-party library recommendation method based on hyperbolic space, see Figure 1 , the method comprising:
[0062] S1: Use the semantic model to embed the APP classification information and TPL label text information into vectors, and transfer the embedded initial feature vectors to the hyperbolic space;
[0063] S2: Unify the feature vector knowledge space through multi-layer perceptron in hyperbolic space, and iteratively calculate the feature vector of APP node and the feature vector of TPL node with the help of Lorentz metric based on the strategy of positive and negative sample comparison to obtain the final node feature vector table, where the final node feature vector table contains APP and TPL call feature information;
[0064] S3: Based on the APP currently selected by the user, recommend qualified third-party libraries to the user in the final feature vector table.
[0065] The specific implementation of each step of the present invention is described in detail below.
[0066] Step S1 can be implemented in the following ways:
[0067] S11: Input the classification of APP and the label text information of TPL into the pre-trained FastText model to obtain the d-dimensional APP initial feature vector and TPL initial feature vector in the Euclidean space;
[0068] S12: The initial eigenvector is transferred from the Euclidean space to the hyperbolic space at the origin through the exponential mapping function exp0(*) of the Lorentz model.
[0069] The calculation formula of the exponential mapping is:
[0070]
[0071] Wherein, e is the vector (1, 0, ..., 0), which is the origin in the hyperbolic space. Represents node Ai The initial eigenvectors in Euclidean space, A i The eigenvector in the hyperbolic space, c is the curvature of the hyperbolic space. is the Lorentz norm, calculated as:
[0072]
[0073] in, is a vector The time dimension of is its component in the spatial dimension.
[0074] In the specific implementation process, step S2 can be implemented in the following way:
[0075] S21: Map the feature vectors of APP nodes and TPL nodes to the tangent space, use a multi-layer perceptron in the tangent space to unify the node feature knowledge space and map it back to the hyperbolic space;
[0076] S22: Construct a loss function through scoring and optimize model parameters through the loss function;
[0077] S23: Repeat step S22 until the maximum number of iterations is reached to obtain a node feature vector table that ultimately contains APP and TPL call feature information.
[0078] Wherein, step S21 can be implemented in the following manner:
[0079] S211: Map the APP and TPL node feature vectors into the tangent space through a projection function;
[0080] The calculation formula of the projection function is:
[0081]
[0082] Wherein, μ0 is the vector (1, 0, ..., 0), which is the origin in the hyperbolic space. is the Lorentz product, A i The eigenvectors in hyperbolic space are, A i Eigenvector in tangent space.
[0083] S212: Update the node feature vector through MLP. The transformation calculation formula of the l-th layer MLP is:
[0084] h (l) =ReLU(,W (l) h (l-1) +b (l) )
[0085] Among them, h (l-1) is the output of the l-1th layer. For the first layer, h (0) is the feature vector of the node. (l) and b (l) are the weight matrix and bias vector of the lth layer respectively, and ReLU is the activation function.
[0086] S213: Map the node feature vector back to the hyperbolic space through an exponential mapping function.
[0087] Step S22 can be implemented in the following manner:
[0088] S221: Calculate the score difference between the positive and negative example node pairs of APP and TPL based on the Lorenz metric, where the positive example is the APP and TPL pair with real call relationship in the training set, and the negative example is the randomly selected APP and TPL pair with no call record. The calculation formula is:
[0089] Rating_minus=lnσ(Rating(A i , T p )-Rating(A i , T n ))
[0090] Among them, σ(·) is the Sigmoid activation function.
[0091] Specifically, for APP node A i and TPL node T j , the scoring formula is:
[0092]
[0093] in, For node A i and TPL node T j The Lorentz product of and are the global preference features of node self-learning, For hyperbolic vector addition, there are two vectors x and y. The calculation formula is:
[0094]
[0095] Where c is the hyperbolic space curvature.
[0096] S222: Repeat step S221 to obtain the score differences of each APP and TPL positive and negative example node pair and add them up.
[0097] S223: Calculate the model parameter probability term according to the pseudo-hyperbolic Gaussian distribution, and the calculation formula is:
[0098]
[0099] Where d is the embedding dimension of the vector in the hyperbolic space, Θ is the set of model parameters, and λ Θ is the regularization parameter and μ0 is the origin of the hyperbolic space.
[0100] S224: Repeat steps S221-S223 to optimize the model parameters, update the node feature vectors of each APP and TPL, and obtain the final feature vector table.
[0101] Preferably, the optimization expression of the model is:
[0102]
[0103] Among them, OPT is the optimization objective function, A i The eigenvector in the hyperbolic space, c is the curvature of the hyperbolic space. is the Lorentz norm, Θ is the set of all parameters, λ Θ is the regularization parameter, μ0 is the origin of the hyperbolic space, and d is the embedding dimension of the vector in the hyperbolic space.
[0104] In the prior art, a third-party library recommendation method based on hybrid collaborative filtering (method 1) is disclosed. A topic model is generated by an unsupervised learning method, and a feature vector is constructed using a knowledge graph. Finally, the recommendation list generated by the topic model and the recommendation list of the knowledge graph are integrated to generate a hybrid recommendation result. The method of the present invention is the same as method 1 as a third-party library recommendation method. The difference is that the model of method 1 is located in the Euclidean space, and the method of the present invention performs iterative learning calculations of feature vectors in the hyperbolic space, and enhances the feature capture accuracy of APP and TPL based on the geometric advantage of hyperbolic space in expressing complex hierarchical structure data, which is located in a different geometric space from the method. "Collaborative filtering recommendation method and system based on hyperbolic space contrast learning" (method 2) Ai constructs a recommendation main task model in the hyperbolic space, combines the contrast learning auxiliary task model for multi-task learning, and generates the final recommendation result. The method of the present invention performs recommendation tasks in the hyperbolic space in the same way as method 2, and can be applied to the third-party library recommendation scenario. The difference is that the hyperbolic graph convolutional neural network is used when learning user and item representations in method 2, and randomly discards edges in the contrast learning auxiliary task to generate a new interaction graph. The method of the present invention constructs a learning objective function based on Bayesian posterior probability when learning feature representation, and incorporates self-learning global preference feature modeling as well as text information such as labels and categories. Compared with method 2, this method has a different model technology route, that is, the technical means used are different. On the basis of method 2, technical personnel in this field can only think of using a hyperbolic graph convolutional neural network to learn user and item representations respectively, and randomly discard edges in contrastive learning auxiliary tasks to generate a new interaction graph, thereby realizing collaborative filtering recommendation.
[0105] The present invention encodes text information such as categories of mobile applications and third-party libraries through a semantic model, effectively retaining information such as categories and labels; effectively transfers node features from different knowledge spaces to a unified knowledge space through a multi-layer perceptron in a hyperbolic space, solving the defect of heterogeneous node information fusion in traditional third-party library recommendation methods; learns the interactive relationship between mobile applications and third-party libraries in a hyperbolic space, and then generates a score ranking based on feature representation, which alleviates the information sparsity problem of tail nodes in the long-tail distribution, improves the accuracy of recommending third-party libraries, and enhances practicality; the model combines historical data with currently selected APP data, and efficiently generates recommendation results for third-party libraries through a locally cacheable vector table, which is feasible in real industrial scenarios with huge data volumes.
[0106] The method of the present invention is described below by means of specific examples, specifically taking AppBrain as an embodiment;
[0107] Experimental preparation: The experimental programming environment is PyTorch 2.0.1, Scipy 1.11.4 and Numpy 1.25.2. AppBrain is a well-known Android mobile application website that covers multi-dimensional information such as the application name, category, description, and called third-party libraries.
[0108] The embodiment retains applications with more than 5 call libraries, and finally obtains the AppBrain dataset containing 667,233 mobile applications, 572 third-party libraries and 11,392,322 call records. In order to simulate real development scenarios of different scales and different application fields, three sub-datasets are divided to evaluate the present invention. The dataset information is shown in Table 1.
[0109]
[0110] like Figure 2 As shown, when the present invention recommends a third-party library, according to the text information and call data of APP and TPL, iterative calculation is performed in hyperbolic space through a multi-layer perceptron and an optimization strategy based on positive and negative example comparison loss, to construct the final APP and TPL feature vector table, and calculate the final third-party library score ranking list. Finally, the top 5 and 10 third-party libraries with the final score are recommended for each APP in the experimental data set, and the average accuracy (Mean Precision, MP), average recall (Mean Recall, MR), hit rate (Hit Rate, HR) and normalized discounted cumulative gain (Normalized Discounted Cumulative Gain, NDCG) indicators of the recommendation results are calculated. The closer each indicator is to 1, the higher the ranking accuracy of the recommendation results.
[0111] The training parameters of the model in the present invention are shown in Table 2.
[0112]
[0113] The final experimental results of the present invention are shown in Table 3.
[0114]
[0115] Embodiment 2
[0116] Based on the same inventive concept, this embodiment discloses a third-party library recommendation device based on hyperbolic space, including:
[0117] The feature vector initialization module is used to perform vector embedding processing on the classification information of APP and the label text information of TPL through the semantic model, and transfer the embedded initial feature vector to the hyperbolic space;
[0118] The final feature vector table acquisition module is used to unify the feature vector knowledge space through the multi-layer perceptron in the hyperbolic space, and iteratively calculate the feature vectors of the APP node and the TPL node with the help of the Lorentz metric based on the strategy of positive and negative sample comparison to obtain the final node feature vector table, wherein the final node feature vector table contains the APP and TPL call feature information;
[0119] The third-party library recommendation module is used to recommend qualified third-party libraries to users in the final feature vector table based on the APP currently selected by the user.
[0120] It should be noted that Figure 2 In the model shown, the embedding initialization module corresponds to the feature vector initialization module in the third-party library recommendation device based on hyperbolic space, the feature representation learning module corresponds to the final feature vector table acquisition module, and the rating prediction module corresponds to the third-party library recommendation module.
[0121] Since the device introduced in the second embodiment of the present invention is a device used to implement the third-party library recommendation method based on the hyperbolic space in the first embodiment of the present invention, based on the method introduced in the first embodiment of the present invention, the person skilled in the art can understand the specific structure and deformation of the device, so it is not repeated here. All devices used in the method in the first embodiment of the present invention belong to the scope of protection of the present invention.
[0122] Embodiment 3
[0123] Based on the same inventive concept, the present invention further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method described in the first embodiment is implemented.
[0124] Since the computer-readable storage medium introduced in the third embodiment of the present invention is the computer-readable storage medium used to implement the third-party library recommendation method based on the hyperbolic space in the first embodiment of the present invention, based on the method introduced in the first embodiment of the present invention, the person skilled in the art can understand the specific structure and deformation of the computer-readable storage medium, so it is not repeated here. All computer-readable storage media used in the method of the first embodiment of the present invention belong to the scope of protection of the present invention.
[0125] Embodiment 4
[0126] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in Embodiment 1 when executing the program.
[0127] Since the computer device introduced in the fourth embodiment of the present invention is a computer device used to implement the third-party library recommendation method based on the hyperbolic space in the first embodiment of the present invention, based on the method introduced in the first embodiment of the present invention, the person skilled in the art can understand the specific structure and deformation of the computer device, so it is not repeated here. All computer devices used in the method of the first embodiment of the present invention belong to the scope of protection of the present invention.
[0128] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0129] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0130] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic creative concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the embodiments of the present invention without departing from the spirit and scope of the embodiments of the present invention. Thus, if these modifications and variations of the embodiments of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. A third-party library recommendation method based on hyperbolic space, characterized in that: include: S1: Use the semantic model to embed the APP classification information and TPL label text information into vectors, and transfer the embedded initial feature vectors to the hyperbolic space; S2: Unify the feature vector knowledge space through multi-layer perceptron in hyperbolic space, and iteratively calculate the feature vector of APP node and the feature vector of TPL node with the help of Lorentz metric based on the strategy of positive and negative sample comparison to obtain the final node feature vector table, where the final node feature vector table contains APP and TPL call feature information; S3: Based on the APP currently selected by the user, recommend qualified third-party libraries to the user in the final feature vector table.
2. The method for recommending a third-party library based on hyperbolic space according to claim 1, characterized in that: Step S1 includes: S11: Input the classification information of the APP and the label text information of the TPL into the pre-trained FastText model to obtain the d-dimensional APP initial feature vector and the TPL initial feature vector in the Euclidean space; S12: The d-dimensional APP initial eigenvector and the TPL initial eigenvector are transferred from the Euclidean space to the hyperbolic space at the origin through the exponential mapping function exp0(*) of the Lorentz model, where the calculation formula of the exponential mapping is: e is the vector (1, 0, ..., 0), which is the origin of the hyperbolic space. Indicates APP node A i The initial eigenvectors in Euclidean space, A i The eigenvector in the hyperbolic space, c is the hyperbolic space curvature, is the Lorentz norm, calculated as: in, yes The time dimension of yes Component in the spatial dimension.
3. The third-party library recommendation method based on hyperbolic space as claimed in claim 1, characterized in that: Step S2 includes: S21: Map the APP node feature vector and the TPL node feature vector to the tangent space, use a multi-layer perceptron in the tangent space to unify the node feature knowledge space and map it back to the hyperbolic space; S22: Construct a loss function by scoring the APP and TPL positive and negative example nodes, and optimize the model parameters through the loss function; S23: Repeat step S22 until the maximum number of iterations is reached to obtain a node feature vector table that finally contains APP and TPL call feature information.
4. The method for recommending a third-party library based on hyperbolic space according to claim 3, characterized in that: Step S21 includes: S211: Map the APP node feature vector and the TPL node feature vector into the tangent space through a projection function, wherein the calculation formula of the projection function is: Where μ0 is the vector (1, 0, ..., 0), which is the origin in the hyperbolic space. is the Lorentz product, APP node A i The eigenvectors in hyperbolic space are, APP node A i Eigenvectors in tangent space; S212: Update the node feature vector through the multi-layer perceptron MLP, where the transformation calculation formula of the l-th layer MLP is: h (l) =ReLU(W (l) h (l-1) +b (l) ) Among them, h (l-1) is the output of the l-1th layer. For the first layer, h (0) is the feature vector of the node, W (l) and b (l) are the weight matrix and bias vector of the lth layer respectively, and ReLU is the activation function; S213: Map the updated node feature vector back to the hyperbolic space through an exponential mapping function.
5. The method for recommending a third-party library based on hyperbolic space according to claim 3, characterized in that: Step S22 includes: S221: Calculate the score difference between the positive and negative example node pairs of APP and TPL based on the Lorentz metric, where the positive example is the APP and TPL pair with a real call relationship in the training set, and the negative example is the randomly selected APP and TPL pair with no call record. The calculation formula for the score difference between the positive and negative example node pairs of APP and TPL is: Rating-minus=lnσ(Rating(A i ,T p )-Rating(A i ,T n )) Among them, σ(·) is the Sigmoid activation function; for APP node A i and TPL node T j , the scoring formula is: For node A i and TPL node T j The Lorentz product of and A i Self-learned global preference features and T j Self-learned global preference features, For hyperbolic vector addition, there are two vectors x and y. The calculation formula is: c is the hyperbolic space curvature; S222: Repeat step S221 to obtain the score differences of each APP and TPL positive and negative example node pair and add them up; S223: Calculate the model parameter probability term according to the pseudo-hyperbolic Gaussian distribution, and the calculation formula is: Where d is the embedding dimension of the vector in the hyperbolic space, Θ is the set of model parameters, and λ Θ is the regularization parameter, μ0 is the origin of the hyperbolic space; S224: Repeat steps S221-S223 to optimize the model parameters, update the node feature vectors of each APP and the node feature vectors of TPL, and obtain the final feature vector table.
6. The method for recommending a third-party library based on hyperbolic space according to claim 5, characterized in that: The optimization objective function of the model is: Among them, OPT is the optimization objective function, A i The eigenvectors in hyperbolic space are, T p The eigenvectors in hyperbolic space are, T n The eigenvectors in hyperbolic space are, T n The global preference feature of self-learning, c is the hyperbolic space curvature, is the Lorentz norm, Θ is the set of all parameters, λ Θ is the regularization parameter, μ0 is the origin of the hyperbolic space, d is the embedding dimension of the vector in the hyperbolic space, and D s A collection of nodes.
7. The method for recommending a third-party library based on hyperbolic space according to claim 1, characterized in that: Step S3 includes: Based on the APP currently selected by the user, the topK algorithm is used to recommend the K third-party libraries with the highest current scores to the user in the final feature vector table.
8. A third-party library recommendation device based on hyperbolic space, characterized in that: include: The feature vector initialization module is used to perform vector embedding processing on the classification information of APP and the label text information of TPL through the semantic model, and transfer the embedded initial feature vector to the hyperbolic space; The final feature vector table acquisition module is used to unify the feature vector knowledge space through the multi-layer perceptron in the hyperbolic space, and iteratively calculate the feature vectors of the APP node and the TPL node with the help of the Lorentz metric based on the strategy of positive and negative sample comparison to obtain the final node feature vector table, wherein the final node feature vector table contains the APP and TPL call feature information; The third-party library recommendation module is used to recommend qualified third-party libraries to users in the final feature vector table based on the APP currently selected by the user.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the third-party library recommendation method based on hyperbolic space as described in any one of claims 1 to 7 is implemented.
10. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the third-party library recommendation method based on hyperbolic space as described in any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Information recommendation and model training method, device and equipment and storage medium
CN110162700A
Commodity recommendation system and method based on deep learning
CN117078342A
Knowledge perception recommendation method for multiple hyperbolic spaces
CN117973535A
Knowledge perception recommendation method and system based on hyperbolic contrast learning, medium and equipment
CN117974272A
Apparatus for controlling wearable Robot using bio signal, Method thereof, and Computer readable storage medium having the method
KR1020200095152A
Cited By
Data processing method and device, storage medium and program product
CN120804500A
Third-party library recommendation method based on multi-relation fusion
CN121167047A
