Giter Club home page Giter Club logo

embeddings-for-trees's Introduction

JetBrains Research Github action: build Code style: black Checked with mypy

Embeddings for trees

Set of PyTorch modules for developing and evaluating different algorithms for embedding trees.

Requirements

You can install the dependencies by using the requirement list

pip install -r requirements.txt

Although it's better to install PyTorch and DGL manually for correct CUDA support.

Data preprocessing

List of some useful tools for preprocessing source code into a dataset with ASTs:

  • ASTMiner - tool for mining raw ASTs and path-based representation of code using ANTLR, GumTree and other grammars.
  • PSIMiner - tool for processing PSI trees from IntelliJ IDEA and creating labeled dataset from them.

Model zoo

This section contains information about implemented models.

TreeLSTM

PyTorch reimplementation of ChildSum version of TreeLSTM presented by Tai et al. in "Improved Semantic Representations From Tree-Structured Long Short-Term Memory Networks".

There are 3 different variantions of these model:

  1. Classic — ChildSum TreeLSTM model for code AST with LSTM+attention decoder that was wisely used in other works To train or test model use:
python -m embeddings_for_trees.treelstm train/test -c $CONFIG_PATH
  1. Typed TreeLSTM — the same classic model, but works with typed AST that were introduced in PSIMiner To train or test model use:
python -m embeddings_for_trees.typed_treelstm train/test -c $CONFIG_PATH
  1. TreeLSTM with pointers — ChildSum TreeLSTM model with pointer network to AST leaves for decoding To train or test model use:
python -m embeddings_for_trees.treelstm_ptr train/test -c $CONFIG_PATH

For config examples see config directory. Classic model and model with pointer network share configurations, while typed model requires specification for token types vocabulary.

Contribution

Supporting different algorithms of encoding and decoding trees is the key area of improvement for this framework. If you have any suggestions or questions, feel free to open issues and create pull requests.

embeddings-for-trees's People

Contributors

dependabot[bot] avatar egor-bogomolov avatar spirinegor avatar

Stargazers

 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

embeddings-for-trees's Issues

Need help to create embeddings

Hi there,
Thank you for this amazing work. I'm trying to create embeddings for ASTs. I generated ASTs for source code using astminer tool. Then I put that file with train.jsonl name inside this project. But I'm facing following error, can you please help with it. I'm a beginner. I'll be really thankful.

Screenshot (22)

How to use embeddings-for-trees output?

Hi,
I'm using this lib to generate embeddings so that I can use them as input to ML model. But output is in form of .ckpt files and I'm finding difficulty to use it.
I tried using wandb.restore() but no success.
I'm a beginner, can you please provide me help regarding output format. I was expecting some form of numerical embedding for ASTs.
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.