Code Monkey home page Code Monkey logo

icse2022_ast_trans's Introduction

ast_trans_icse

This is the implementation for AST-Trans: Code Summarization with Efficient Tree-Structured Attention.

1. install environments

pip install -r requirements.

pytorch-geometric can be installed by pip install torch-scatter torch-sparse torch-cluster torch-spline-conv torch-geometric -f https://pytorch-geometric.com/whl/torch-1.9.0+cu102.html

2.pre process data

this step attends to generate pot, sbt, paths and relationship matrices of ASTs. The dataset we proposed have been pre-processed. If you want to pre-process the dataset of your own, you can save ASTs as a json object of format like {'type':'';'value':'','children':[]}, and then run:

python pre_process/process.py --data_dir your_data_set_path --max_ast_len 250 --process --make_vocab

PS: Due to the limited storage of the cloud drive, I accidentally deleted the data and code. Fortunately, in the work of [1, 2], they use tree-sitter to process and extract the data required for ast-trans. That is really cool! So if you are interested in the pre-process process, you can find the detail in their repositor1, repository2.

[1] Oh, Saeyoon, and Shin Yoo. "CSA-Trans: Code Structure Aware Transformer for AST." arXiv preprint arXiv:2404.05767 (2024).

[2] Sun W, Fang C, Miao Y, et al. Abstract Syntax Tree for Programming Language Understanding and Representation: How Far Are We?[J]. arXiv preprint arXiv:2312.00413, 2023.

3. run

we use py_config_runner. The config of model is saved at ./config. you need to change 'data_dir' to your own data set path. clearml is also supported in our implementation. if you do not want to use it, just set:

use_clearml = False

For run AST-Trans:

single-gpu:

python main.py --config ./config/ast_trans.py --g 0

multi-gpu:

python -u -m torch.distributed.launch --nproc_per_node=2 --use_env main.py --config=./config/ast_trans.py --g 0,1

4. test

For test, you can set the parameter 'is_test' to True. and set the checkpoint file path. The program will default find the checkpoint based on the hype-parameters. And we apply a trained AST-Trans checkpoint file for python in https://box.nju.edu.cn/f/ebdb250c46524268be41/. If you want to load model on your specific path, just change the 'load_epoch_path' of the test function in script/train.py

load_epoch_path = './checkpoint/'

icse2022_ast_trans's People

Contributors

zetang94 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

icse2022_ast_trans's Issues

Requirements file lacks PyTorch Geometric version

requirements.txt seems to lack the specific version of PyTorch Geometric being used here. The API has changed considerably over the last two years and it'd be of much help if you could update the requirements file.

Cannot reproduct the result

Hi, I use the same hyper params as the paper described (expect that the batch size is 32), and the result on the python dataset is:

bleu: 33.57576184454644, rouge: 40.749804328727144 meteor: 20.408711947772836

This is lower than that of the original paper, especially the rouge metric (47.14 -> 40.74), which is a large drop.

Is this the final version of you code? Or I should use a larger batch size?

Please help me, thanks!

preprocess dataset

Can you upload the data AST processing as {'type':''; 'value':'','children':[]} script? Your data preprocessing method, thank you very much

when set use_clearml = False,there is an error.

Dear Author:
when I set "use_clearml = False", there will be an error""ClearML configuration could not be found (missing ~/clearml.conf or Environment CLEARML_API_HOST)\n"ValueError: ClearML configuration could not be found (missing ~/clearml.conf or Environment CLEARML_API_HOST) To get started with ClearML: setup your own clearml-server, or create a free account at https://app.clear.ml". I guess the reason may be: in the exp_tracking.py, the variable "has_clearml"=True, however, I cannot set the variable to be False because there will be a RuntimeError "No experiment tracking system is setup. " "Please, setup either ClearML. ". What should I do to solve this problem.

when I set "use_clearml" = True, there will be an error "ValueError: ClearML configuration could not be found (missing ~/clearml.conf or Environment CLEARML_API_HOST) To get started with ClearML: setup your own clearml-server, or create a free account at https://app.clear.ml" . I have no idea about the clearml. when I search on the Internet, I cannot find something helpful. I am looking for your help. Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.