All Projects → tech-srl → slm-code-generation

tech-srl / slm-code-generation

Licence: MIT license
TensorFlow code for the neural network presented in the paper: "Structural Language Models of Code" (ICML'2020)

Programming Languages

java
68154 projects - #9 most used programming language
python
139335 projects - #7 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to slm-code-generation

XcodeCommentWrapper
Xcode extension for wrapping comments
Stars: ✭ 29 (-61.33%)
Mutual labels:  code, source
Opengrok
OpenGrok is a fast and usable source code search and cross reference engine, written in Java
Stars: ✭ 3,452 (+4502.67%)
Mutual labels:  code, source
larapos
Laravel Point of sale with invoice full source code free download pos apps.
Stars: ✭ 38 (-49.33%)
Mutual labels:  code, source
Mat-O-Wahl
🇩🇪 Mat-O-Wahl - Ein einfach zu bedienender, freier Open Source Wahl-O-Mat Klon fuer jedermann ### 🇬🇧 🇺🇸 A simple to handle, free "Voting Advice Application" / "Electoral Compass" alternative
Stars: ✭ 27 (-64%)
Mutual labels:  code, source
Ssti Payloads
🎯 Server Side Template Injection Payloads
Stars: ✭ 150 (+100%)
Mutual labels:  code, source
lowcode
React Lowcode - prototype, develop and maintain internal apps easier
Stars: ✭ 32 (-57.33%)
Mutual labels:  code, codegen
Updated Carbanak Source With Plugins
https://twitter.com/itsreallynick/status/1120410950430089224
Stars: ✭ 303 (+304%)
Mutual labels:  code, source
Clangkit
ClangKit provides an Objective-C frontend to LibClang. Source tokenization, diagnostics and fix-its are actually implemented.
Stars: ✭ 330 (+340%)
Mutual labels:  code, source
Tr2main
Tomb Raider II Injector Dynamic Library
Stars: ✭ 46 (-38.67%)
Mutual labels:  code, source
Tomb5
Tomb Raider: Chronicles Disassembly translated to C source code.
Stars: ✭ 397 (+429.33%)
Mutual labels:  code, source
Golang Notes
Go source code analysis(zh-cn)
Stars: ✭ 3,137 (+4082.67%)
Mutual labels:  code, source
Windowsxp
This is the leaked source code of Windows XP Service Pack 1
Stars: ✭ 164 (+118.67%)
Mutual labels:  code, source
Spring Cloud Codegen
Spring Cloud代码生成器
Stars: ✭ 203 (+170.67%)
Mutual labels:  code, codegen
generator
Any Code generator
Stars: ✭ 421 (+461.33%)
Mutual labels:  codegen
100daysOfMakie
100 days of Makie examples
Stars: ✭ 67 (-10.67%)
Mutual labels:  code
Dashi
💯 Get a notification in Slack every time someone asks you to check some code on Github or Bitbucket.
Stars: ✭ 29 (-61.33%)
Mutual labels:  code
vicopo
API HTTP et Script pour trouver les villes à partir d'un code postal et code postaux à partir d'une ville
Stars: ✭ 27 (-64%)
Mutual labels:  code
CPPNotes
【C++ 面试 + C++ 学习指南】 一份涵盖大部分 C++ 程序员所需要掌握的核心知识。
Stars: ✭ 557 (+642.67%)
Mutual labels:  code
get-source
Fetch source-mapped sources. Peek by file, line, column. Node & browsers. Sync & async.
Stars: ✭ 26 (-65.33%)
Mutual labels:  source
Pwc
Papers with code. Sorted by stars. Updated weekly.
Stars: ✭ 15,288 (+20284%)
Mutual labels:  code

SLM: Structural Language Models of Code

This is an official implementation of the model described in:

"Structural Language Models of Code" [PDF]

Appeared in ICML'2020.

An online demo is available at https://AnyCodeGen.org.

This repository currently contains the dataset and the data extractor that we used to create the Java dataset in the paper.

Feel free to open a new issue for any question. We always respond quickly.

Table of Contents

Requirements

  • python3
  • TensorFlow 1.13 or newer (install). To check TensorFlow version:

python3 -c 'import tensorflow as tf; print(tf.__version__)'

Download our preprocessed Java-small dataset

This dataset contains ~1.3M examples (1.1GB).

mkdir data
cd data
wget https://codegen-slm.s3.us-east-2.amazonaws.com/data/java-small-preprocessed.tar.gz
tar -xvzf java-small-preprocessed.tar.gz

This will create a data/java-small/ sub-directory, containing the files that hold training, test and validation sets, a dict file for various dataset properties and histograms, and a grammar file that is used during beam search to distinguish between terminal and non-terminal nodes.

Creating and preprocessing a new Java dataset

To create and preprocess a new dataset (for example, to compare SLM to a new model on another dataset):

  • Edit the file preprocess.sh using the instructions there, pointing it to the correct training, validation and test directories.
  • Run the preprocess.sh file:

bash preprocess.sh

Datasets

Java

To download the Java-small as raw *.java files, use:

To download the preprocessed dataset, use:

To download the dataset in a tokenized format that can be used in seq2seq models (for example, with OpenNMT-py), use:

The following JSON files are the files that are created by the JavaExtractor. The preprocessed and the seq2seq files are created from these JSON files:

Every line is a JSON object that contains the following fields: num_targets, num_nodes, targets, is_token, target_child_id, internal_paths, relative_paths, head_paths, head_root_path, head_child_id, linearized_tree, filepath, left_context, right_context, target_seq, line.

C#

The C# dataset that we used in the paper was created using the raw (*.cs files) dataset of Allamanis et al., 2018, (https://aka.ms/iclr18-prog-graphs-dataset) and can be found here: https://aka.ms/iclr18-prog-graphs-dataset.

To extract examples from the C# files, we modified the data extraction code of Brockschmidt et al., 2019: https://github.com/microsoft/graph-based-code-modelling/.

Querying the Trained Model

To query the trained model, use the following API, where MYCODE is the given code snippet, that includes two question marks (??) to mark the "hole" that should be completed.

To query the expression-prediction model (the "paper model" in the demo website):

curl -X POST https://w0w3uc4a63.execute-api.us-east-1.amazonaws.com/prod/predict -d '{"code": "MYCODE"}'

For example:

curl -X POST https://w0w3uc4a63.execute-api.us-east-1.amazonaws.com/prod/predict -d '{"code": "public static Path[] stat2Paths(FileStatus[] stats) {  if (stats == null) return null;  Path[] ret = new Path[stats.length]; for (int i = 0; i < stats.length; ++i) { ret[i] = ??; } return ret; }"}'

To query the statement-prediction model (the "extended model" in the demo website):

curl -X POST https://63g9yqims7.execute-api.us-east-1.amazonaws.com/prod/predict -d '{"code": "MYCODE"}'

For example:

curl -X POST https://63g9yqims7.execute-api.us-east-1.amazonaws.com/prod/predict -d '{"code": "@Override public boolean retainAll(Collection<?> collection) { boolean changed = false;     for (Iterator<E> iter = iterator(); iter.hasNext(); ) {         Element elem = iter.next();        if (!collection.contains(elem)) {           iter.remove();             ??        }    }    return changed;}"}'

Citation

Structural Language Models of Code

@inproceedings{alon2020structural,
  title={Structural language models of code},
  author={Alon, Uri and Sadaka, Roy and Levy, Omer and Yahav, Eran},
  booktitle={International Conference on Machine Learning},
  pages={245--256},
  year={2020},
  organization={PMLR}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].