Atten-TPL: A multimodal TPL recommendation model based on attention mechanism
Creators: name: Anonymous
Publisher: name: Zenodo
Year: 2024

description: Here is the relevant dataset and open-source code for the article titled "Atten-TPL: A multimodal TPL recommendation model based on attention mechanism"





The “Atten-TPL” folder includes datasets used for experiment and the code of our proposed Atten-TPL model.




The “Baseline” folder contains the codes of all baseline models, including: CrossRec, LibSeek, GRec, HCF.



Atten-TPL

Usage

Step 1. Generating training data and testing data

The data used for experiment is stored in sub folder of "data". After executing load_data.py, two sub-folders named "training data" and "testing data" will be created. These two folders respectively store five-fold data for training and testing, respectively.

Step 2. Model training

Simply start Python in COMMAND LINE mode, then use the following statement (one line in the COMMAND Prompt window) to execute train_model.py:

python train_model.py --train_dataset training_0.json --weight_decay 0.0001 --lr 0.01 
--continue_training 0 --train_batch_size 1024 --epoch 2

Once the program execution is complete, it will generate a folder named "model_Atten_TPL", where the trained model is stored.

Step 3. Model testing

Start Python in COMMAND LINE mode, then use the following statement (one line in the COMMAND Prompt window) to execute test_model.py:

python test_model.py --test_dataset testing_0_3.json

Once the program execution is complete, it will generate a folder named "output", where the recommendation results is stored.

Step 4. Metrics evaluation

Start Python in COMMAND LINE mode, then use the following statement (one line in the COMMAND Prompt window) to execute metrics.py:

python metrics.py --rm 3

Then, you may receive the results as follows:

MP_rm: 0.665159, MR_rm: 0.665159, MF_rm: 0.665159, MAP_rm: 0.887698, COV_rm: 0.585845
MP_2rm: 0.391802, MR_2rm: 0.783604, MF_2rm: 0.522403, MAP_2rm: 0.852650, COV_2rm: 0.639581

Environment Settup

Our code has been tested under Python 3.12.3. The experiment was conducted via PyTorch, and thus the following packages are required:

torch == 1.3.1
numpy == 1.18.1
scipy == 1.3.2
sklearn == 0.21.3

Updated version of each package is acceptable.

Description of Essential Folders and Files






Name



Type



Description





data



Folder



Data files required for the experiment. Specifically: relation_shuffle.json contains the apps used in the experiment and their corresponding TPLs. app_info.json contains the description texts for each app, which are crawled from app stores or third-party websites. app_function.json contains the functionas extracted from each app description text.





train_model.py



File



Model training python file of AttenTPL





test_model.py



File



Model testing python file of AttenTPL





model_Atten_TPL.py



File



Model modules of AttenTPL





utility



Folder



Tools and essential libraries used by AttenTPL





function feature



Folder



The vectoring results of app functions.





Other Important module of AttenTPL

Obtaining app functions from description

Users could obtain app functions from description by executing the obtain_function.py. The program utilizes GPT-3.5 Turbo model to analyze the description text of the app and extract its functions.





Obtain an API Key

Before using this program, you need an OpenAI API key. If you don't have one yet, you can register and obtain it from the OpenAI website.




Configure the API Key

In the code file obtain_function.py, locate openai.api_key = "" on line 8 and insert your API key within the quotation marks.




Execute the Program

Locate description = "" on line 32 and insert the app description within the quotation marks. Then, execute the program to obtain app functions.



Vectoring app function

Users could represents the function list of app product with a vector by executing the vectoring_function.py. The program represents the function list with a vector by utilizing the Sentence-Bert model.





Install dependency

Ensure you have the necessary dependency installed. You can install it using the pip command: pip install -U Sentence-transformers




Execute the Program

Provide the list of function sentences in the functions variable. Then, execute the program to obtain obtain feature vectors for app functions.



Baseline method

CrossRec

This is a method that employs the CF-based technique to recommend TPLs for target open-source projects.

To provide further insight into this method, you can read the original paper:



Nguyen, Phuong T., et al. "CrossRec: Supporting software developers by recommending third-party libraries." Journal of Systems and Software 161 (2020): 110460.


LibSeek

This method employs a matrix factorization model to find potentially useful TPLs for apps.

To provide further insight into this method, you can read the original paper:



He, Qiang, et al. "Diversified third-party library prediction for mobile app development." IEEE Transactions on Software Engineering 48.1 (2020): 150-165.


GRec

This is the first GNN-based TPL recommendation method, and it models the app-TPL interactions as a graph and utilizes GNN to process the graph to provide potentially available TPLs for apps.

To provide further insight into this method, you can read the original paper:



Li, B., He, Q., Chen, F., Xia, X., Li, L., Grundy, J.,and Yang, Y., 2021. Embedding App-Library Graph for Neural Third Party Library Recommendation. In proceddings of FSE 2021. DOI:10.1145/3468264.3468552


HCF

This is the state-of-the-art GNN-based TPL recommendation method, and it can return more accurate and diverse recommendation results than other GNN-based methods by modeling apps and TPLs as two hypergraphs and using hypergraph neural network (HGNN) to process these hypergraphs.

To provide further insight into this method, you can read the original paper:



Chen, Lianrong, et al. "High-Order Collaborative Filtering for Third-Party Library Recommendation." 2023 IEEE International Conference on Web Services (ICWS). IEEE, 2023.