Giter Site home page Giter Site logo

seeker71 / micsas Goto Github PK

View Code? Open in Web Editor NEW

This project forked from intellabs/micsas

0.0 1.0 0.0 76.05 MB

MISIM: A Neural Code Semantics Similarity System Using the Context-Aware Semantics Structure

License: MIT License

Makefile 0.43% Python 75.28% CMake 1.48% C++ 22.17% Shell 0.64%

micsas's Introduction

MICSAS: Machine Inferred Code Semantics Analysis System

MICSAS (also known as MISIM) is a neural code semantics similarity system that introduces a novel code representation named context-aware semantics structure (CASS in short) and a neural-backend that supports various neural network architectures.

Further details can be found in the technical paper titled "A Neural Code Semantics Similarity System Using the Context-Aware Semantics Structure" by Fangke Ye, Shengtian Zhou, Anand Venkat, Ryan Marcus, Nesime Tatbul, Jesmin Jahan Tithi, Niranjan Hasabnis, Paul Petersen, Timothy Mattson, Tim Kraska, Pradeep Dubey, Vivek Sarkar, Justin Gottschlich.

Requirements

  • Python 3.7.6
  • Python packages
    • absl-py 0.9.0
    • numpy 1.18.1
    • pyprg 0.1.1b7
    • regex 2020.4.4
    • scipy 1.4.1
    • sklearn 0.0
    • torch 1.6.0
    • torch-scatter 2.0.5
    • tqdm 4.42.1
    • tree-sitter 0.1.1
    • wget 3.2
    • networkx 2.6
  • CMake
  • C++14 compatible compiler
  • Clang++ 3.7.1 (optional, for the preprocessing step of Neural Code Comprehension)

Training

  1. Data preprocessing

    • Run ./preprocess.sh (clang++-3.7.1 required), or
    • Download preprocessed datasets from here and extract them into data/.
  2. Training

    Use the commands below to train each model described in the paper:

    python train.py <model_name> --split data/datasets/split_<dataset_name>.pkl -f data/datasets/<dataset_name>/dataset-<model_name> --save data/models/<dataset_name>/<model_name>
    

    <dataset_name> can be one of:

    • poj (POJ-104)
    • gcj (Google Code Jam)

    <model_name> can be one of:

    • gnn (MISIM-GNN)
    • sbt (MISIM-RNN)
    • bof (MISIM-BoF)
    • c2v (code2vec)
    • ncc (Neural Code Comprehension with inst2vec)

    To train the Neural Code Comprehension model without inst2vec, use the following command:

    python train.py ncc -noi2v --split data/datasets/split_<dataset_name>.pkl -f data/datasets/<dataset_name>/dataset-ncc --save data/models/<dataset_name>/ncc-noi2v
    

    Pre-trained models are available here. They include the models trained with three different random seeds, and were used to obtain the evaluation results in the paper.

Evaluation

For deep learninig models including MISIM, code2vec, and Neural Code Comprehension, use the following command to compute and print the evaluation metrics (<model_file> is the name of the model file (model.pt) obtained from training):

python train.py <model_name> --split data/datasets/split_<dataset_name>.pkl -f data/datasets/<dataset_name>/dataset-<model_name> --load <model_file>

To evaluate Aroma, use the following commands:

# Aroma-Dot
python aroma.py -f data/datasets/<dataset_name>/dataset-aroma --split data/datasets/split_<dataset_name>.pkl --sim dot

# Aroma-Cos
python aroma.py -f data/datasets/<dataset_name>/dataset-aroma --split data/datasets/split_<dataset_name>.pkl --sim cos

micsas's People

Contributors

shengtianzhou avatar nhasabni avatar

Watchers

James Cloos avatar

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.